Alexey Dolotov 6 gün önce
ebeveyn
işleme
29a134802a
No account linked to committer's email address

+ 4
- 5
contrib/sni-router/README.md Dosyayı Görüntüle

@@ -27,10 +27,9 @@ natural and passive DPI has nothing to flag.
27 27
 # 2. Generate an mtg secret:
28 28
 docker run --rm nineseconds/mtg:2 generate-secret --hex YOUR_DOMAIN
29 29
 
30
-# 3. Edit the config files:
31
-#    - mtg-config.toml  →  paste the secret
32
-#    - haproxy.cfg       →  replace "example.com" in the SNI ACL
33
-#    - .env or export    →  DOMAIN=your.domain
30
+# 3. Configure:
31
+#    - .env (or export)  →  DOMAIN=your.domain   # used by HAProxy + Caddy
32
+#    - mtg-config.toml   →  paste the secret
34 33
 
35 34
 # 4. (Optional) put your site content into www/
36 35
 
@@ -83,7 +82,7 @@ domain's DNS A/AAAA record points to this server before starting.
83 82
 | File | Purpose |
84 83
 |---|---|
85 84
 | `docker-compose.yml` | Service definitions |
86
-| `haproxy.cfg` | SNI routing rules — **edit the domain** |
85
+| `haproxy.cfg` | SNI routing rules (reads `$DOMAIN` from the environment) |
87 86
 | `mtg-config.toml` | mtg proxy config — **paste your secret** |
88 87
 | `Caddyfile` | Web server config (auto-HTTPS) |
89 88
 | `www/` | Static site content served by Caddy |

+ 12
- 5
contrib/sni-router/docker-compose.yml Dosyayı Görüntüle

@@ -9,13 +9,18 @@
9 9
 # SNI/IP because the domain resolves to this server's IP.
10 10
 #
11 11
 # Quick start:
12
-#   1. Set YOUR_DOMAIN below (and in mtg-config.toml)
13
-#   2. docker compose up -d
14
-#   3. mtg generate-secret YOUR_DOMAIN   -> put it in mtg-config.toml
15
-#   4. docker compose restart mtg
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
14
+#   3. docker compose up -d
15
+#
16
+# DOMAIN is forwarded to both Caddy (TLS cert) and HAProxy (SNI ACL),
17
+# so the SNI/cert/secret all line up from a single source.
16 18
 #
17 19
 # See BEST_PRACTICES.md and the project wiki for background.
18 20
 
21
+x-domain-env: &domain-env
22
+  DOMAIN: ${DOMAIN:-example.com}
23
+
19 24
 services:
20 25
   haproxy:
21 26
     image: haproxy:lts-alpine
@@ -24,6 +29,8 @@ services:
24 29
       - "80:80"
25 30
     volumes:
26 31
       - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro,Z
32
+    environment:
33
+      <<: *domain-env
27 34
     depends_on:
28 35
       - mtg
29 36
       - web
@@ -51,7 +58,7 @@ services:
51 58
       - "80"
52 59
       - "8443"
53 60
     environment:
54
-      DOMAIN: ${DOMAIN:-example.com}
61
+      <<: *domain-env
55 62
     restart: unless-stopped
56 63
 
57 64
 volumes:

+ 4
- 3
contrib/sni-router/haproxy.cfg Dosyayı Görüntüle

@@ -39,9 +39,10 @@ frontend tls
39 39
     tcp-request inspect-delay 5s
40 40
     tcp-request content accept if { req_ssl_hello_type 1 }
41 41
 
42
-    # Route Telegram clients to mtg.
43
-    # Replace "example.com" with the domain from your mtg secret.
44
-    use_backend mtg if { req_ssl_sni -i example.com }
42
+    # Route Telegram clients to mtg.  The domain is read from the $DOMAIN
43
+    # environment variable (forwarded by docker-compose), so it stays in
44
+    # sync with Caddy and there is no per-deploy edit to this file.
45
+    use_backend mtg if { req_ssl_sni -i "${DOMAIN}" }
45 46
 
46 47
     default_backend web
47 48
 

+ 3
- 3
contrib/sni-router/mtg-config.toml Dosyayı Görüntüle

@@ -1,8 +1,8 @@
1 1
 # Minimal mtg configuration for the SNI-router setup.
2 2
 #
3
-# 1. Generate a secret:  mtg generate-secret --hex example.com
4
-# 2. Paste it below.
5
-# 3. Replace example.com with your actual domain everywhere.
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).
6 6
 
7 7
 secret = "PASTE_YOUR_SECRET_HERE"
8 8
 bind-to = "0.0.0.0:3128"

Loading…
İptal
Kaydet