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.

haproxy.cfg 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # HAProxy SNI router — Layer 4 (TCP mode)
  2. #
  3. # Inspects the SNI in the TLS ClientHello and routes traffic:
  4. # - SNI matching the mtg secret domain -> mtg (FakeTLS / MTProto)
  5. # - Everything else -> real web backend (Caddy)
  6. #
  7. # Because routing happens before TLS termination, each backend sees the
  8. # raw ClientHello and handles TLS itself. The real web backend therefore
  9. # presents a genuine certificate to any probe or browser.
  10. global
  11. log stdout format raw local0 info
  12. maxconn 4096
  13. defaults
  14. log global
  15. mode tcp
  16. option tcplog
  17. timeout connect 5s
  18. timeout client 60s
  19. timeout server 60s
  20. # --- HTTP :80 — redirect to HTTPS -------------------------------------------
  21. frontend http
  22. bind *:80
  23. mode http
  24. http-request redirect scheme https code 301
  25. # --- TLS :443 — SNI-based routing -------------------------------------------
  26. frontend tls
  27. bind *:443
  28. tcp-request inspect-delay 5s
  29. tcp-request content accept if { req_ssl_hello_type 1 }
  30. # Route Telegram clients to mtg.
  31. # Replace "example.com" with the domain from your mtg secret.
  32. use_backend mtg if { req_ssl_sni -i example.com }
  33. default_backend web
  34. backend mtg
  35. server mtg mtg:3128
  36. backend web
  37. server web web:8443