Improve reverse proxy work, add captive portal detection#112
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the deployment templates to better support Tailscale behaviour and more accurate client IP handling when running Headscale behind a reverse proxy (Caddy).
Changes:
- Add a dedicated
/generate_204handler to both HTTP and HTTPS Caddy templates to support Tailscale captive portal detection. - Introduce a
trusted_proxiessection in the Headscale config template to control when proxy-provided client IP headers are honoured.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| templates/headscale.template.yaml | Adds trusted_proxies configuration for trusted reverse proxy CIDRs. |
| templates/Caddyfile-https.template | Adds /generate_204 handler returning HTTP 204 before other handlers. |
| templates/Caddyfile-http.template | Adds /generate_204 handler returning HTTP 204 before other handlers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
I took this comment wholesale from upstream, but hardcoded localhost at the same time... Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
This pull request adds support for Tailscale captive portal detection and improves reverse proxy handling in the configuration templates. The main changes are the addition of a handler for the
/generate_204endpoint in both HTTP and HTTPS Caddyfile templates, and the introduction of atrusted_proxiessetting in the Headscale YAML template to properly honor client IP headers from trusted proxies.Captive portal detection:
/generate_204in bothCaddyfile-http.templateandCaddyfile-https.templateto respond with HTTP 204, supporting Tailscale's captive portal detection mechanism. [1] [2]Reverse proxy configuration:
trusted_proxiessection inheadscale.template.yamlto specify which proxy IP ranges are trusted forTrue-Client-IP,X-Real-IP, andX-Forwarded-Forheaders, improving security and correct client IP logging.