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.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 -> 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.
  18. #
  19. # See BEST_PRACTICES.md and the project wiki for background.
  20. x-domain-env: &domain-env
  21. DOMAIN: ${DOMAIN:-example.com}
  22. services:
  23. haproxy:
  24. image: haproxy:lts-alpine
  25. # Host networking so HAProxy sees the real client source IP on
  26. # inbound (bridge networking with published ports rewrites it to
  27. # the bridge gateway under both Docker's userland-proxy and
  28. # rootless Podman's slirp4netns/pasta). See "Why host networking"
  29. # in README.md.
  30. network_mode: host
  31. volumes:
  32. - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro,Z
  33. environment:
  34. <<: *domain-env
  35. depends_on:
  36. - mtg
  37. - web
  38. restart: unless-stopped
  39. mtg:
  40. image: nineseconds/mtg:2
  41. volumes:
  42. - ./mtg-config.toml:/config/config.toml:ro,Z
  43. # Publish on host loopback so the host-mode HAProxy can reach it.
  44. ports:
  45. - "127.0.0.1:3128:3128"
  46. restart: unless-stopped
  47. extra_hosts:
  48. - "host.containers.internal:host-gateway"
  49. web:
  50. image: caddy:alpine
  51. volumes:
  52. - ./Caddyfile:/etc/caddy/Caddyfile:ro,Z
  53. - caddy_data:/data
  54. - ./www:/srv:ro,Z
  55. # Publish on host loopback so the host-mode HAProxy can reach it.
  56. # Caddy's HTTP listener is mapped off :80 (occupied by HAProxy)
  57. # to :8080; haproxy.cfg dials it on 127.0.0.1:8080 for ACME.
  58. ports:
  59. - "127.0.0.1:8080:80"
  60. - "127.0.0.1:8443:8443"
  61. environment:
  62. <<: *domain-env
  63. restart: unless-stopped
  64. volumes:
  65. caddy_data: