Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

docker-compose.yml 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # SNI-routing deployment: HAProxy (443) -> mtg + real web backend
  2. #
  3. # This setup puts an SNI-aware TCP router in front of mtg so that:
  4. # - Telegram clients (FakeTLS with the correct SNI) are routed to mtg
  5. # - All other TLS traffic (including DPI probes) reaches the real web
  6. # server, which responds with a genuine certificate
  7. #
  8. # The result: active probes see a real website; passive DPI sees matching
  9. # SNI/IP because the domain resolves to this server's IP.
  10. #
  11. # Quick start:
  12. # 1. Set DOMAIN in a .env file next to this one (or export it)
  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.
  17. # 3. docker compose up -d
  18. #
  19. # DOMAIN is forwarded to both Caddy (TLS cert) and HAProxy (SNI ACL),
  20. # so the SNI/cert/secret all line up from a single source.
  21. #
  22. # See BEST_PRACTICES.md and the project wiki for background.
  23. x-domain-env: &domain-env
  24. DOMAIN: ${DOMAIN:-example.com}
  25. services:
  26. haproxy:
  27. image: haproxy:lts-alpine
  28. # Host netns so HAProxy sees real client IPs (v4/v6) instead of the
  29. # bridge gateway address. Linux host only; see README → "Why HAProxy
  30. # uses network_mode: host" for the rationale and trade-off.
  31. network_mode: host
  32. volumes:
  33. - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro,Z
  34. environment:
  35. <<: *domain-env
  36. depends_on:
  37. - mtg
  38. - web
  39. restart: unless-stopped
  40. mtg:
  41. # FIXME: :master until #480 lands in a tagged release; switch back to :2/:3 after release
  42. image: nineseconds/mtg:master
  43. volumes:
  44. - ./mtg-config.toml:/config/config.toml:ro,Z
  45. # Published on host loopback only — HAProxy (host netns) reaches it via
  46. # 127.0.0.1.
  47. ports:
  48. - "127.0.0.1:3128:3128"
  49. restart: unless-stopped
  50. extra_hosts:
  51. - "host.containers.internal:host-gateway"
  52. web:
  53. image: caddy:alpine
  54. volumes:
  55. - ./Caddyfile:/etc/caddy/Caddyfile:ro,Z
  56. - caddy_data:/data
  57. - ./www:/srv:ro,Z
  58. # Published on host loopback only — HAProxy reaches Caddy on 127.0.0.1.
  59. # Port 8080 (not 80) on the host because HAProxy already owns host :80.
  60. ports:
  61. - "127.0.0.1:8080:80"
  62. - "127.0.0.1:8443:8443"
  63. environment:
  64. <<: *domain-env
  65. restart: unless-stopped
  66. volumes:
  67. caddy_data: