Skip to content

custom proxy domain - #188

Open
marcomc wants to merge 21 commits into
0.5.xfrom
feature/custom-proxy-domain
Open

custom proxy domain#188
marcomc wants to merge 21 commits into
0.5.xfrom
feature/custom-proxy-domain

Conversation

@marcomc

@marcomc marcomc commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds configurable multi-domain support for the Global Proxy while keeping my127.site as the built-in default domain.

Changes

  • Adds machine-level proxy domain registry support via ~/.config/my127/workspace/proxy-domains.yml.
  • Adds ws global service proxy config domain ... commands for listing, adding, updating, removing, and importing domains.
  • Adds proxy runtime commands for generating Traefik host rules, TLS config, and downloading configured certificates.
  • Moves Global Proxy host rules into generated .env values while keeping the existing Docker Compose service layout.
  • Updates proxy, mail, logger, and tracing service init scripts to refresh generated proxy rules.
  • Adds concise upstream docs and cheatsheet entries for custom proxy domains.
  • Adds PHPUnit coverage for proxy domain management, runtime rule generation, TLS config generation, and certificate downloads.

Notes

  • my127.site remains the default and is not persisted in the registry.

Testing

  • vendor/bin/phpunit tests/Test/GlobalService/Proxy --testdox
  • php -d phar.readonly=0 vendor/bin/phpunit --testdox
  • vendor/bin/phpstan analyse --memory-limit=1G
  • vendor/bin/php-cs-fixer fix --dry-run --diff --config=.php-cs-fixer.php src/GlobalService/Proxy tests/Test/GlobalService/Proxy

marcomc added 6 commits June 15, 2026 12:37
- Added support for dynamic Traefik rules in mail, proxy, and tracing services using environment variables.
- Implemented a new CertificateDownloader class for downloading certificates from specified URLs.
- Introduced ProxyDomainCommand for managing proxy domains, including add, update, remove, and import functionalities.
- Enhanced ProxyDomainConfiguration to handle domain normalization and conflict checks.
- Updated init scripts for mail, proxy, and tracing services to utilize new domain management features.
- Added tests for ProxyDomainCommand and ProxyRuntimeCommand to ensure proper functionality of domain management and TLS configurations.
touch .flag-built
else
run docker-compose -p my127ws-logger start
run docker-compose -p my127ws-logger up -d

@marcomc marcomc Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start would not pick up the new generated Traefik rule.
Logger now writes TRAEFIK_KIBANA_RULE into .env before enabling the service. That value is used inside the Compose labels:

    labels:
      - traefik.enable=true
      - traefik.http.routers.kibana.rule=${TRAEFIK_KIBANA_RULE}

docker-compose up -d reconciles the Compose project: if the interpolated label changed, it recreates the affected container; if nothing changed, it is effectively a start/no-op.

Comment thread home/lib/sidekick.sh
echo -ne "\\033[1E" >&2
}

updateEnvGeneratedKey()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updates one generated key in a .env file.

It rewrites the file by removing any existing line that starts with the same KEY=, preserves all other lines, then appends the new KEY=value at the end.

use my127\Console\Usage\Input;
use Symfony\Component\Yaml\Yaml;

class ProxyDomainCommand

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProxyDomainCommand manages the registered proxy-domain data.

It handles user-facing registry operations such as:

  • list domains
  • add domain
  • update domain
  • remove domain
  • import domains

@andytson-inviqa andytson-inviqa Jun 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supporting multiple domains seems quite complex.

I wonder if we could keep it down to one with a custom option/env var file override the config file or folder to read from, which is more common in multi use tools

like docker compose -f alternate-compose.yml ...

DOCKER_COMPOSE_FILE=alternate-compose.yml docker compose ...

@andytson-inviqa andytson-inviqa Jun 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, well it'd mean you couldn't run both proxies at the same time as they bind to same host port, but it's quite troubling this PR complexity, when ideally we should be lowering complexity

@marcomc marcomc Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to keep compatibility with my127.site
so that a developer could work on multiple projects: some that still use the my127.site while other projects might ported to a custom domain progressively.


use my127\Console\Usage\Input;

class ProxyRuntimeCommand

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProxyRuntimeCommand turns the effective proxy-domain config into runtime artifacts used by services.

It handles generated output such as:

  • Traefik host rules
  • Traefik TLS YAML
  • downloaded certificate files


use Symfony\Component\Yaml\Yaml;

class ProxyDomainConfiguration

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProxyDomainConfiguration validates and normalizes proxy-domain definitions.

It handles:

  • built-in default domain injection
  • valid proxy-domain IDs
  • valid bare DNS names
  • required certificate/key URLs
  • derived certificate/key filenames
  • duplicate domain/filename conflict checks


use Symfony\Component\Yaml\Yaml;

class ProxyDomainRegistry

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProxyDomainRegistry reads and writes the user-managed proxy-domain registry file.

It handles:

  • reading domains from ~/.config/my127/workspace/proxy-domains.yml
  • writing registered domains back to that file
  • creating the config directory when needed
  • excluding the built-in default domain from the saved registry


use Symfony\Component\Yaml\Yaml;

class ProxyRuntimeConfiguration

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProxyRuntimeConfiguration converts proxy-domain config into Traefik runtime config.

It handles:

  • generating Traefik Host(...) rules for services
  • mapping services to host prefixes, such as mail. or kibana.
  • generating Traefik TLS YAML
  • pointing Traefik at local /tls/*.crt and /tls/*.key files


namespace my127\Workspace\GlobalService\Proxy;

class CertificateDownloader

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CertificateDownloader downloads configured certificate material onto disk.

It handles:

  • resolving the TLS output directory
  • downloading certificate/key URLs
  • writing them using the configured local filenames
  • cleaning up temporary files if a download fails

Comment thread src/Types/Workspace/Workspace.php
Comment thread src/Types/Attribute/Collection.php
{
return $this->attributes->getAttributeMetadata($key);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function attributeMetadata is needed because domain update/remove must know whether the effective domain comes from proxy-domains.yml, given that it only edits proxy-domains.yml.

@marcomc
marcomc requested a review from kierenevans June 16, 2026 16:38
@marcomc
marcomc marked this pull request as ready for review June 16, 2026 16:38
@marcomc marcomc added the enhancement New feature or request label Jun 16, 2026
Comment on lines +11 to +16
$serviceHostPrefix = [
'proxy' => '',
'mail' => 'mail.',
'logger' => 'kibana.',
'tracing' => 'tracing.',
];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels a bit centralised being here rather than in the services, not obvious to update this if a new service is created

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I can change the command so that no longer takes a service name.
Instead of:

global service proxy config rule <service>

it becomes:

global service proxy config rule [<host-prefix>]

So the proxy runtime no longer needs a centralized service => host prefix map. Each service passes the public hostname prefix it wants to expose:

mail     -> config rule mail
logger   -> config rule kibana
tracing  -> config rule tracing
proxy    -> config rule

This also means a future service can use any hostname prefix without having to update a centralised map, and the prefix does not need to match the service name.

would that me good for you?

@andytson-inviqa andytson-inviqa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this level of complexity when the only real goal is to make the my127.site domain reconfigurable.

Start small and simple with just making the 'my127.site' string and cert path configurable by configuration file only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants