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
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

docker-compose.yml 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. # network_mode: host lets HAProxy see real client source IPs (v4 and v6)
  29. # instead of the docker/podman bridge gateway. Bridge ingress (docker-proxy
  30. # userland forwarder, podman slirp4netns/pasta) rewrites the source address
  31. # of inbound connections to the gateway; with host networking HAProxy binds
  32. # in the host netns directly and the rewrite never happens. See the
  33. # "Real client IPs" section of README.md.
  34. #
  35. # Trade-off: HAProxy occupies host :443 and :80. Don't run anything else
  36. # on those ports.
  37. network_mode: host
  38. volumes:
  39. - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro,Z
  40. environment:
  41. <<: *domain-env
  42. depends_on:
  43. - mtg
  44. - web
  45. restart: unless-stopped
  46. mtg:
  47. # FIXME: :master until #480 lands in a tagged release; switch back to :2/:3 after release
  48. image: nineseconds/mtg:master
  49. volumes:
  50. - ./mtg-config.toml:/config/config.toml:ro,Z
  51. # Published on host loopback only — HAProxy (host netns) reaches it via
  52. # 127.0.0.1:3128. Not exposed on any public interface.
  53. ports:
  54. - "127.0.0.1:3128:3128"
  55. restart: unless-stopped
  56. extra_hosts:
  57. - "host.containers.internal:host-gateway"
  58. web:
  59. image: caddy:alpine
  60. volumes:
  61. - ./Caddyfile:/etc/caddy/Caddyfile:ro,Z
  62. - caddy_data:/data
  63. - ./www:/srv:ro,Z
  64. # Published on host loopback only — HAProxy reaches Caddy on 127.0.0.1.
  65. ports:
  66. - "127.0.0.1:8080:80"
  67. - "127.0.0.1:8443:8443"
  68. environment:
  69. <<: *domain-env
  70. restart: unless-stopped
  71. volumes:
  72. caddy_data: