ソースを参照

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

contrib/sni-router: render mtg-config.toml from a tracked .example
pull/528/head
Sergei Arkhipov 2ヶ月前
コミット
a3ff5ca6b6
コミッターのメールアドレスに関連付けられたアカウントが存在しません

+ 5
- 0
contrib/sni-router/.gitignore ファイルの表示

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
 
29
 
30
 # 3. Configure:
30
 # 3. Configure:
31
 #    - .env (or export)  →  DOMAIN=your.domain   # used by HAProxy + Caddy
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
 # 4. (Optional) put your site content into www/
39
 # 4. (Optional) put your site content into www/
35
 
40
 
120
 |---|---|
125
 |---|---|
121
 | `docker-compose.yml` | Service definitions |
126
 | `docker-compose.yml` | Service definitions |
122
 | `haproxy.cfg` | SNI routing rules (reads `$DOMAIN` from the environment) |
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
 | `Caddyfile` | Web server config (auto-HTTPS) |
130
 | `Caddyfile` | Web server config (auto-HTTPS) |
125
 | `www/` | Static site content served by Caddy |
131
 | `www/` | Static site content served by Caddy |

+ 4
- 1
contrib/sni-router/docker-compose.yml ファイルの表示

10
 #
10
 #
11
 # Quick start:
11
 # Quick start:
12
 #   1. Set DOMAIN in a .env file next to this one (or export it)
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
 #   3. docker compose up -d
17
 #   3. docker compose up -d
15
 #
18
 #
16
 # DOMAIN is forwarded to both Caddy (TLS cert) and HAProxy (SNI ACL),
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
-# 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
 bind-to = "[::]:3128"
15
 bind-to = "[::]:3128"
9
 
16
 
10
 # HAProxy in front sends PROXY protocol v2 headers so mtg can see the
17
 # HAProxy in front sends PROXY protocol v2 headers so mtg can see the

読み込み中…
キャンセル
保存