Conversation
Turnkey deployment: HAProxy on :443 peeks at the TLS SNI and routes Telegram clients to mtg while forwarding everything else (including DPI probes) to a real Caddy web server with automatic HTTPS. This is the setup recommended in BEST_PRACTICES.md, packaged so that operators can clone and run it with minimal configuration. Refs: 9seconds#458
Add an ACL that routes /.well-known/acme-challenge/ requests on :80 to Caddy instead of redirecting to HTTPS, so Let's Encrypt certificate issuance works out of the box. Also simplify Caddyfile to use Caddy's http_port/https_port directives.
The default [defense.blocklist] uses firehol_level1.netset, which includes bogon networks and therefore all RFC1918 ranges. Clients connecting from a LAN address (e.g. a phone on the home Wi-Fi when mtg runs at home) are silently rejected with "ip was blacklisted" and routed to the fronting domain. This is a recurring source of confusion (see issue 9seconds#466 for the latest example). Add a warning next to the urls list in example.config.toml and a Troubleshooting section in README.md covering the symptom, the cause, and three resolution paths (disable blocklist, swap for a narrower list, or use hairpin NAT). Docs only, no code changes.
The previous wording ("silently routed to the fronting domain")
is inaccurate. In mtglib/proxy.go the blocklist path calls
conn.Close() immediately with no further handshake or fronting;
domain fronting only happens on FakeTLS failures for non-blocked
IPs. Reword to "TCP connection is closed with no response" so
users searching the docs get the same symptom they actually see.
Without this, mtg and Caddy see HAProxy's container IP for every connection, which breaks meaningful logging, abuse handling, and any IP-based blocklist logic. HAProxy sends a PROXY protocol v2 header on its TCP backends; mtg enables proxy-protocol-listener, and Caddy wraps :8443 with a proxy_protocol listener before tls. The :80 path (ACME HTTP-01 passthrough) is unchanged — client IP there is not useful and HAProxy's http mode already adds X-Forwarded-For if anyone wants it. Requested in 9seconds#462 review.
Add docker-compose example with HAProxy SNI router
docs: warn about firehol_level1 RFC1918 gotcha in default blocklist
Upstream commits included: - 0c1d001 Add docker-compose example with HAProxy SNI router - d0412b2 Fix ACME HTTP-01 passthrough in HAProxy config - 602f85d Document firehol_level1 RFC1918 gotcha in blocklist defaults - 68a4685 Fix description of blocklist rejection behavior - 170346b Pass real client IPs through with PROXY protocol v2 - 5953f93 Merge PR 9seconds#462 from dolonet/contrib/docker-sni-router - 9bf7222 Merge PR 9seconds#467 from dolonet/docs/blocklist-lan-gotcha Conflict resolution: README.md kept as fork version (mtg-multi has its own README describing multi-secret and per-user stats features). example.config.toml auto-merged cleanly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Merges 7 upstream commits from 9seconds/mtg into master.
0c1d001d0412b2170346b602f85d68a46855953f939bf7222Net changes: 7 new files under
contrib/sni-router/, additions toexample.config.toml. No code changes.Conflict resolution:
README.mdkept as fork version (fork README is independently maintained).example.config.tomlauto-merged cleanly.