-
Notifications
You must be signed in to change notification settings - Fork 13
Feature/simple custom proxy domain #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marcomc
wants to merge
19
commits into
0.5.x
Choose a base branch
from
feature/simple-custom-proxy-domain
base: 0.5.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1859682
feat: add TLS configuration for proxy service in workspace.yml
marcomc c660f3d
feat: update proxy service configurations to use dynamic domain varia…
marcomc 830868e
feat: simplify enable function in init scripts and add TLS configurat…
marcomc f82d195
feat: add tests for global proxy domain configuration and overrides
marcomc ee3ff1a
feat: add documentation for custom global proxy domain configuration
marcomc 17dd727
feat: remove unused environment variables from proxy service command …
marcomc f3fa4b4
feat: add descriptions for logger and tracing service commands in glo…
marcomc bd2ecb2
feat: enhance create command with description and exec block formatting
marcomc 29bcfa4
feat: update attribute source handling to use latest source and highe…
marcomc 97804ec
feat: update offsetGet method to return mixed type and add test for a…
marcomc 6582f60
feat: add MY127WS_PROXY_DOMAIN export in service init scripts and tes…
marcomc 0241a4e
feat: add tracing service environment file to files-bin in box.json
marcomc e13be5a
feat: enhance global proxy configuration with environment variable su…
marcomc 9a4bf43
feat: add TLS validation functions to ensure certificate and key file…
marcomc cac212c
feat: enhance global proxy service tests with TLS validation and erro…
marcomc 3c7ac04
feat: update documentation for proxy configuration with HTTPS require…
marcomc 283b292
feat: implement proxy environment population and update service initi…
marcomc adeb1b3
feat: update init script to use dynamic workspace binary reference fo…
marcomc 1b9e48b
feat: enhance workspace binary reference handling and update proxy en…
marcomc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,231 @@ | ||
| # Custom Global Proxy Domain | ||
|
|
||
| Workspace uses `my127.site` by default for local HTTPS hostnames. You can | ||
| replace that single Global Proxy domain with another domain by adding a global | ||
| Workspace config file on the developer machine. | ||
|
|
||
| This feature supports one proxy domain at a time. It does not register multiple | ||
| domains. | ||
|
|
||
| ## Contents | ||
|
|
||
| - [How it fits together](#how-it-fits-together) | ||
| - [Create the proxy config file](#create-the-proxy-config-file) | ||
| - [Host the certificate files](#host-the-certificate-files) | ||
| - [Configure DNS](#configure-dns) | ||
| - [Apply the change](#apply-the-change) | ||
| - [Use the domain in a project](#use-the-domain-in-a-project) | ||
| - [Renew certificates](#renew-certificates) | ||
|
|
||
| ## How it fits together | ||
|
|
||
| Workspace automatically loads global config files from: | ||
|
|
||
| ```text | ||
| ~/.config/my127/workspace/*.yml | ||
| ``` | ||
|
|
||
| Use `proxy.yml` for the proxy override: | ||
|
|
||
| ```text | ||
| ~/.config/my127/workspace/proxy.yml | ||
| ``` | ||
|
|
||
| `proxy.yml` is a normal Workspace global config file. It is not fetched from a | ||
| remote URL and it is not managed by a Workspace import command. | ||
|
|
||
| ```mermaid | ||
| flowchart LR | ||
| configFile["~/.config/my127/workspace/proxy.yml"] | ||
| attributes["global.service.proxy.* attributes"] | ||
| commands["ws global service proxy restart"] | ||
| init["home/service/proxy/init.sh"] | ||
| compose["docker-compose labels"] | ||
| tlsFiles["traefik/root/tls/<cert files>"] | ||
| tlsConfig["traefik/root/config/tls.yaml"] | ||
| traefik["Single Traefik Global Proxy"] | ||
|
|
||
| configFile --> attributes | ||
| attributes --> commands | ||
| commands --> init | ||
| init --> compose | ||
| init --> tlsFiles | ||
| init --> tlsConfig | ||
| compose --> traefik | ||
| tlsFiles --> traefik | ||
| tlsConfig --> traefik | ||
| ``` | ||
|
|
||
| The configured values are passed to Docker Compose as environment variables at | ||
| runtime. The source of truth remains the global Workspace config file. | ||
|
|
||
| ## Create the proxy config file | ||
|
|
||
| Minimal `~/.config/my127/workspace/proxy.yml`: | ||
|
|
||
| ```yaml | ||
| attribute('global.service.proxy.domain'): dev.example.test | ||
| attribute('global.service.proxy.https.crt'): https://proxy-config.example.internal/certs/dev.example.test/fullchain.pem | ||
| attribute('global.service.proxy.https.key'): https://proxy-config.example.internal/certs/dev.example.test/privkey.pem | ||
| ``` | ||
|
|
||
| The local certificate filenames default to: | ||
|
|
||
| ```text | ||
| <domain>.crt | ||
| <domain>.key | ||
| ``` | ||
|
|
||
| For the example above, Workspace writes: | ||
|
|
||
| ```text | ||
| traefik/root/tls/dev.example.test.crt | ||
| traefik/root/tls/dev.example.test.key | ||
| ``` | ||
|
|
||
| Override the local filenames only when needed: | ||
|
|
||
| ```yaml | ||
| attribute('global.service.proxy.https.crt_file'): proxy.crt | ||
| attribute('global.service.proxy.https.key_file'): proxy.key | ||
| ``` | ||
|
|
||
| Full example: | ||
|
|
||
| ```yaml | ||
| attribute('global.service.proxy.domain'): dev.example.test | ||
| attribute('global.service.proxy.https.crt'): https://proxy-config.example.internal/certs/dev.example.test/fullchain.pem | ||
| attribute('global.service.proxy.https.key'): https://proxy-config.example.internal/certs/dev.example.test/privkey.pem | ||
| attribute('global.service.proxy.https.crt_file'): dev.example.test.crt | ||
| attribute('global.service.proxy.https.key_file'): dev.example.test.key | ||
| ``` | ||
|
|
||
| ## Host the certificate files | ||
|
|
||
| The certificate and key URLs must be reachable from each developer machine when | ||
| `ws global service proxy restart` runs. | ||
|
|
||
| The files do not need to live beside `proxy.yml`. `proxy.yml` only stores the | ||
| URLs where Workspace can download them. | ||
|
|
||
| Suggested hosted structure: | ||
|
|
||
| ```text | ||
| proxy-config/ | ||
| └── certs/ | ||
| └── dev.example.test/ | ||
| ├── fullchain.pem | ||
| └── privkey.pem | ||
| ``` | ||
|
|
||
| GitHub raw URLs work only for public repositories because Workspace does not | ||
| authenticate to GitHub. Use public GitHub raw URLs only for disposable test | ||
| certificates. | ||
|
|
||
| Example public GitHub repository structure: | ||
|
|
||
| ```text | ||
| workspace-proxy-certs/ | ||
| └── certs/ | ||
| └── dev.example.test/ | ||
| ├── fullchain.pem | ||
| └── privkey.pem | ||
| ``` | ||
|
|
||
| Example `proxy.yml` using GitHub raw URLs: | ||
|
|
||
| ```yaml | ||
| attribute('global.service.proxy.domain'): dev.example.test | ||
| attribute('global.service.proxy.https.crt'): https://raw.githubusercontent.com/my-org/workspace-proxy-certs/main/certs/dev.example.test/fullchain.pem | ||
| attribute('global.service.proxy.https.key'): https://raw.githubusercontent.com/my-org/workspace-proxy-certs/main/certs/dev.example.test/privkey.pem | ||
| ``` | ||
|
|
||
| For organisation/private certificates, use an internal HTTP(S) location that is | ||
| reachable from developer machines, such as a private website available on the | ||
| company network or VPN. | ||
|
|
||
| The certificate must cover the configured domain and the subdomains used by | ||
| projects and global services. For `dev.example.test`, the certificate should | ||
| cover: | ||
|
|
||
| ```text | ||
| dev.example.test | ||
| *.dev.example.test | ||
| ``` | ||
|
|
||
| The wildcard covers project hosts and global service hosts such as: | ||
|
|
||
| ```text | ||
| mail.dev.example.test | ||
| kibana.dev.example.test | ||
| tracing.dev.example.test | ||
| ``` | ||
|
|
||
| ## Configure DNS | ||
|
|
||
| The configured domain and wildcard subdomains must resolve to the developer | ||
| machine running the Workspace Global Proxy. | ||
|
|
||
| For local development, common options are: | ||
|
|
||
| - public DNS records that point the domain and wildcard to `127.0.0.1`; | ||
| - private DNS records available only on the organisation network; | ||
| - local DNS tools such as Pi-hole, dnsmasq, or `/etc/hosts` for individual | ||
| hostnames. | ||
|
|
||
| Wildcard support is recommended because project hostnames are usually generated | ||
| under the proxy domain. | ||
|
|
||
| ## Apply the change | ||
|
|
||
| After creating or changing `proxy.yml`, restart the proxy: | ||
|
|
||
| ```bash | ||
| ws global service proxy restart | ||
| ``` | ||
|
|
||
| The restart downloads the certificate and key, renders Traefik TLS config, and | ||
| recreates the proxy container. | ||
|
|
||
| If mail, logger, or tracing are already running, restart those services too so | ||
| their Docker labels use the new hostnames: | ||
|
|
||
| ```bash | ||
| ws global service mail enable | ||
| ws global service logger enable | ||
| ws global service tracing restart | ||
| ``` | ||
|
|
||
| ## Use the domain in a project | ||
|
|
||
| Projects should use the same proxy domain suffix configured globally. For | ||
| example: | ||
|
|
||
| ```yaml | ||
| attributes: | ||
| domain: dev.example.test | ||
| ``` | ||
|
|
||
| Project hostnames should then be under that suffix, such as: | ||
|
|
||
| ```text | ||
| my-project.dev.example.test | ||
| ``` | ||
|
|
||
| This simplified proxy configuration supports one certificate/domain set at a | ||
| time. If the proxy is configured for `dev.example.test`, projects still using | ||
| `my127.site` may no longer match the active certificate. | ||
|
|
||
| ## Renew certificates | ||
|
|
||
| When a certificate is renewed, keep the hosted certificate URLs stable and | ||
| replace the file contents at those URLs. | ||
|
|
||
| Then run: | ||
|
|
||
| ```bash | ||
| ws global service proxy restart | ||
| ``` | ||
|
|
||
| You only need to edit `proxy.yml` when the domain, certificate URL, key URL, or | ||
| local filename changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proxy domain is now part of the Docker Compose labels.
With the previous flow, after the first build
enableonly randocker-compose start. That starts the existing container as-is, so label changes are not applied.If
global.service.proxy.domainchanges, mail/logger could otherwise keep stale labels such asmail.my127.siteorkibana.my127.site.Using
docker-compose up -d --buildkeeps the command idempotent while allowing Compose to recreate the container when the labels/config changed.