Преглед изворни кода

Merge pull request #525 from 9seconds/contrib/sni-router-config-example

contrib/sni-router: render mtg-config.toml from a tracked .example
master
Sergei Arkhipov пре 4 дана
родитељ
комит
a3ff5ca6b6
No account linked to committer's email address

+ 5
- 0
contrib/sni-router/.gitignore Прегледај датотеку

@@ -0,0 +1,5 @@
1
+# Rendered from mtg-config.toml.example; contains the live secret.
2
+mtg-config.toml
3
+
4
+# Local environment overrides (DOMAIN, MTG_SECRET, ...)
5
+.env

+ 8
- 2
contrib/sni-router/README.md Прегледај датотеку

@@ -29,7 +29,12 @@ docker run --rm nineseconds/mtg:2 generate-secret --hex YOUR_DOMAIN
29 29
 
30 30
 # 3. Configure:
31 31
 #    - .env (or export)  →  DOMAIN=your.domain   # used by HAProxy + Caddy
32
-#    - mtg-config.toml   →  paste the secret
32
+#    - render mtg-config.toml from the tracked template
33
+#      (the rendered file is gitignored — secret stays out of git):
34
+export MTG_SECRET=...    # paste the hex secret from step 2
35
+envsubst < mtg-config.toml.example > mtg-config.toml
36
+#      (Or `cp mtg-config.toml.example mtg-config.toml` and edit ${MTG_SECRET}
37
+#      by hand if you don't have envsubst.)
33 38
 
34 39
 # 4. (Optional) put your site content into www/
35 40
 
@@ -120,6 +125,7 @@ domain's DNS A/AAAA record points to this server before starting.
120 125
 |---|---|
121 126
 | `docker-compose.yml` | Service definitions |
122 127
 | `haproxy.cfg` | SNI routing rules (reads `$DOMAIN` from the environment) |
123
-| `mtg-config.toml` | mtg proxy config — **paste your secret** |
128
+| `mtg-config.toml.example` | mtg proxy config template — render with `envsubst` or copy + edit |
129
+| `mtg-config.toml` | Rendered mtg proxy config (gitignored, contains your secret) |
124 130
 | `Caddyfile` | Web server config (auto-HTTPS) |
125 131
 | `www/` | Static site content served by Caddy |

+ 4
- 1
contrib/sni-router/docker-compose.yml Прегледај датотеку

@@ -10,7 +10,10 @@
10 10
 #
11 11
 # Quick start:
12 12
 #   1. Set DOMAIN in a .env file next to this one (or export it)
13
-#   2. mtg generate-secret YOUR_DOMAIN   -> paste into mtg-config.toml
13
+#   2. mtg generate-secret YOUR_DOMAIN   -> render mtg-config.toml:
14
+#        export MTG_SECRET=...     # paste the hex secret
15
+#        envsubst < mtg-config.toml.example > mtg-config.toml
16
+#      (the rendered file is gitignored). See README.md for the cp+edit variant.
14 17
 #   3. docker compose up -d
15 18
 #
16 19
 # DOMAIN is forwarded to both Caddy (TLS cert) and HAProxy (SNI ACL),

contrib/sni-router/mtg-config.toml → contrib/sni-router/mtg-config.toml.example Прегледај датотеку

@@ -1,10 +1,17 @@
1
-# Minimal mtg configuration for the SNI-router setup.
1
+# Minimal mtg configuration template for the SNI-router setup.
2 2
 #
3
-# 1. Generate a secret:  mtg generate-secret --hex <your.domain>
4
-# 2. Paste it into the `secret` field below.
5
-# 3. Set DOMAIN=<your.domain> in .env (HAProxy + Caddy pick it up).
3
+# This is the tracked template; `docker compose` mounts `mtg-config.toml`
4
+# (gitignored), so render or copy this file before `docker compose up -d`:
5
+#
6
+#   1. Set DOMAIN=<your.domain> in .env (HAProxy + Caddy pick it up).
7
+#   2. Generate the secret:  mtg generate-secret --hex <your.domain>
8
+#   3. Produce mtg-config.toml — pick one:
9
+#        export MTG_SECRET=...     # paste the hex secret
10
+#        envsubst < mtg-config.toml.example > mtg-config.toml
11
+#      or just copy and hand-edit `${MTG_SECRET}`:
12
+#        cp mtg-config.toml.example mtg-config.toml && $EDITOR mtg-config.toml
6 13
 
7
-secret = "PASTE_YOUR_SECRET_HERE"
14
+secret = "${MTG_SECRET}"
8 15
 bind-to = "[::]:3128"
9 16
 
10 17
 # HAProxy in front sends PROXY protocol v2 headers so mtg can see the

Loading…
Откажи
Сачувај