-
Notifications
You must be signed in to change notification settings - Fork 13
custom proxy domain #188
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
base: 0.5.x
Are you sure you want to change the base?
custom proxy domain #188
Changes from all commits
aab4b7a
5e585dd
9735ea2
e2c18e8
f44a784
1bd146b
077d98c
b1c0cd0
fed1ba8
8b233c2
498730c
5be6146
2ef1a66
20aaf8d
c8288fd
a15989b
8e50383
97f2dfb
750b99f
84d0402
e598829
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| # Custom Global Proxy domains | ||
|
|
||
| Workspace uses `my127.site` by default for local HTTPS hostnames. You can also | ||
| register extra Global Proxy domains on your machine, so different projects can | ||
| use different DNS suffixes while sharing the same Traefik proxy. | ||
|
|
||
| ## Contents | ||
|
|
||
| - [Register a domain](#register-a-domain) | ||
| - [Host the proxy configuration files](#host-the-proxy-configuration-files) | ||
| - [Use a domain in a project](#use-a-domain-in-a-project) | ||
|
|
||
| Registered domains are stored in: | ||
|
|
||
| ```text | ||
| ~/.config/my127/workspace/proxy-domains.yml | ||
| ``` | ||
|
|
||
| The built-in `my127.site` domain remains available by default. Do not add it to | ||
| `proxy-domains.yml`; that file is for extra domains registered on the machine. | ||
|
|
||
| ## Register a domain | ||
|
|
||
| A proxy domain must be registered before the Global Proxy can serve it. The | ||
| certificate and key must be reachable `http://` or `https://` URLs. | ||
|
|
||
| Certificate URLs may point at private locations that are already reachable from | ||
| the machine, such as an internal HTTP(S) endpoint. | ||
|
|
||
| The certificate must cover the bare domain and the subdomains used by projects | ||
| or global services. For example, a certificate for `mydomain.site` should also | ||
| cover `*.mydomain.site`. | ||
|
|
||
| ## Host the proxy configuration files | ||
|
|
||
| Before developers import a custom proxy domain, the organisation needs stable | ||
| HTTP(S) URLs for: | ||
|
|
||
| - `domains.yml`: the Workspace proxy domain configuration to import. | ||
| - `fullchain.pem`: the certificate served by the Global Proxy. | ||
| - `privkey.pem`: the private key used by that certificate. | ||
|
|
||
| The files do not need to live in the same repository, website, or directory. | ||
| The certificate and key URLs are read from the attributes in `domains.yml`; the | ||
| layout below keeps them together only to make the example easy to follow. | ||
|
|
||
| GitHub raw URLs work only for public repositories because Workspace does not | ||
| authenticate to GitHub. Use them for `domains.yml`, or for disposable test | ||
| certificates. For private keys, use organisation-only HTTP(S) URLs reachable | ||
| from developer machines. | ||
|
|
||
| Suggested structure for one or more domains: | ||
|
|
||
| ```text | ||
| proxy-config/ | ||
| ├── domains.yml | ||
| └── certs/ | ||
| ├── mydomain.site/ | ||
| │ ├── fullchain.pem | ||
| │ └── privkey.pem | ||
| └── otherdomain.site/ | ||
| ├── fullchain.pem | ||
| └── privkey.pem | ||
| ``` | ||
|
|
||
| `domains.yml` can reference any number of domains. Each entry should point to | ||
| the hosted certificate and key URLs for that domain. When certificates are | ||
| renewed, update the hosted certificate files and keep the URLs stable, then | ||
| developers only need to restart the Global Proxy. Re-import `domains.yml` only | ||
| when registering a new machine or adding a domain; use `domain update` when an | ||
| existing domain definition changes. | ||
|
|
||
| The following commands are alternatives for common tasks. Run the one that | ||
| matches the change you want to make. | ||
|
|
||
| ```bash | ||
| # List registered proxy domains. | ||
| ws global service proxy config domain list | ||
|
|
||
| # Register one domain manually. | ||
| ws global service proxy config domain add mydomain \ | ||
| --name=mydomain.site \ | ||
| --crt=https://proxy-config.example.internal/certs/mydomain.site/fullchain.pem \ | ||
| --key=https://proxy-config.example.internal/certs/mydomain.site/privkey.pem | ||
|
|
||
| # Import domains from a local file. | ||
| ws global service proxy config domain import domains.yml | ||
|
|
||
| # Import domains from a public GitHub repository. | ||
| ws global service proxy config domain import https://raw.githubusercontent.com/my-org/public-proxy-config/main/domains.yml | ||
|
|
||
| # Import domains from an internal website. | ||
| ws global service proxy config domain import https://proxy-config.example.internal/domains.yml | ||
|
|
||
| # Replace one registered domain. | ||
| ws global service proxy config domain update mydomain \ | ||
| --name=mydomain.site \ | ||
| --crt=https://proxy-config.example.internal/certs/mydomain.site/fullchain.pem \ | ||
| --key=https://proxy-config.example.internal/certs/mydomain.site/privkey.pem | ||
|
|
||
| # Remove one registered domain. | ||
| ws global service proxy config domain remove mydomain | ||
| ``` | ||
|
|
||
| Example `domains.yml`: | ||
|
|
||
| ```yaml | ||
| attributes: | ||
| global: | ||
| service: | ||
| proxy: | ||
| domains: | ||
| mydomain: | ||
| name: mydomain.site | ||
| https: | ||
| crt: https://proxy-config.example.internal/certs/mydomain.site/fullchain.pem | ||
| key: https://proxy-config.example.internal/certs/mydomain.site/privkey.pem | ||
| crt_file: mydomain.site.crt | ||
| key_file: mydomain.site.key | ||
| otherdomain: | ||
| name: otherdomain.site | ||
| https: | ||
| crt: https://proxy-config.example.internal/certs/otherdomain.site/fullchain.pem | ||
| key: https://proxy-config.example.internal/certs/otherdomain.site/privkey.pem | ||
| crt_file: otherdomain.site.crt | ||
| key_file: otherdomain.site.key | ||
| ``` | ||
|
|
||
| After changing registered domains, restart the proxy: | ||
|
|
||
| ```bash | ||
| ws global service proxy restart | ||
| ``` | ||
|
|
||
| Enabled global services such as mail, logger, or tracing may also need a | ||
| restart before they pick up the new host rules. | ||
|
|
||
| ## Use a domain in a project | ||
|
|
||
| A project uses the normal `domain` attribute. Register the proxy domain first, | ||
| then set the project domain: | ||
|
|
||
| ```yaml | ||
| attributes: | ||
| domain: mydomain.site | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| TRAEFIK_NETWORK=my127ws | ||
| TRAEFIK_KIBANA_RULE=Host(`kibana.my127.site`) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,15 +17,25 @@ main() | |
| disable | ||
| exit | ||
| fi | ||
|
|
||
| if [ "$1" = "restart" ]; then | ||
| restart | ||
| exit | ||
| fi | ||
| } | ||
|
|
||
| enable() | ||
| { | ||
| local TRAEFIK_KIBANA_RULE | ||
|
|
||
| TRAEFIK_KIBANA_RULE="$(ws global service proxy config rule kibana)" | ||
| updateEnvGeneratedKey ".env" "TRAEFIK_KIBANA_RULE" "$TRAEFIK_KIBANA_RULE" | ||
|
|
||
| if [ ! -f .flag-built ]; then | ||
| run docker-compose -p my127ws-logger up -d --build | ||
| touch .flag-built | ||
| else | ||
| run docker-compose -p my127ws-logger start | ||
| run docker-compose -p my127ws-logger up -d | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| fi | ||
| } | ||
|
|
||
|
|
@@ -34,6 +44,12 @@ disable() | |
| run docker-compose -p my127ws-logger stop | ||
| } | ||
|
|
||
| restart() | ||
| { | ||
| disable | ||
| enable | ||
| } | ||
|
|
||
| bootstrap() | ||
| { | ||
| DIR="$(cd "$(dirname "$0")" && pwd)" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| TRAEFIK_NETWORK=my127ws | ||
| TRAEFIK_MAIL_RULE=Host(`mail.my127.site`) |
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.
updates one generated key in a
.envfile.It rewrites the file by removing any existing line that starts with the same
KEY=, preserves all other lines, then appends the newKEY=valueat the end.