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
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

docker-compose.yml 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 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
  16. #
  17. # See BEST_PRACTICES.md and the project wiki for background.
  18. services:
  19. haproxy:
  20. image: haproxy:lts-alpine
  21. ports:
  22. - "443:443"
  23. - "80:80"
  24. volumes:
  25. - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro,Z
  26. depends_on:
  27. - mtg
  28. - web
  29. restart: unless-stopped
  30. sysctls:
  31. - net.ipv4.ip_unprivileged_port_start=80
  32. networks:
  33. - sni
  34. mtg:
  35. image: nineseconds/mtg:2
  36. volumes:
  37. - ./mtg-config.toml:/config/config.toml:ro,Z
  38. expose:
  39. - "3128"
  40. restart: unless-stopped
  41. extra_hosts:
  42. - "host.containers.internal:host-gateway"
  43. networks:
  44. - sni
  45. web:
  46. image: caddy:alpine
  47. volumes:
  48. - ./Caddyfile:/etc/caddy/Caddyfile:ro,Z
  49. - caddy_data:/data
  50. - ./www:/srv:ro,Z
  51. expose:
  52. - "80"
  53. - "8443"
  54. environment:
  55. DOMAIN: ${DOMAIN:-example.com}
  56. restart: unless-stopped
  57. networks:
  58. sni:
  59. # Pinned IP so mtg's `domain-fronting.ip` (which only accepts a
  60. # literal IP, not a hostname) can target Caddy directly and
  61. # bypass HAProxy. See README "Fronting loop" section.
  62. ipv4_address: 172.28.0.10
  63. volumes:
  64. caddy_data:
  65. networks:
  66. sni:
  67. driver: bridge
  68. ipam:
  69. config:
  70. - subnet: 172.28.0.0/24