Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reverse proxy documentation #790

Merged
merged 12 commits into from Sep 21, 2022
Merged

Conversation

mike-lloyd03
Copy link
Contributor

  • Add reverse proxy documentation
  • Update changelog
  • read the CONTRIBUTING guidelines
  • raised a GitHub issue or discussed it on the projects chat beforehand
  • added unit tests
  • added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

Per our discussion on Discord today, I'm adding a brief description for how to configure a reverse proxy in front of Headscale. The doc is rather concise so please let me know where more information is needed. This only covers nginx for now but more proxy servers can be added as necessary.

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This config won't work with Headscale 0.17.x & Tailscale > 1.30.0.

You are missing something like this for proxying WebSockets https://discord.com/channels/896711691637780480/896711692120129540/1015993290417504336

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm actually running 0.17.1-alpha right now and I have the Upgrade and Connection headers set but didn't include them in this PR because I didn't really know what they did haha.

Anyway, I did a bit more research and added them in. I'm not sure if the map variable is needed though. In my configuration, I just have the Connection header set to upgrade. I included it anyway. Let me know what you think.

Running Headscale behind a reverse proxy is suitable for container-based deployments. This is especially useful on a server were port 443 is already being used for other web services.

Headscale can be configured not to use TLS, leaving it to the reverse proxy to handle. Add the following configuration values to your headscale config file.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please point out that for Headscale v0.17.x+ having the reverse proxy configured to support WebSockets is mandatory? Otherwise Tailscale clients v1.30+ will not work.

WebSockets is also required when running the embedded DERP server.

In the embedded DERP case, even if you run a reverse proxy you will also have to open the specified STUN UDP port (see https://github.com/juanfont/headscale/blob/main/config-example.yaml#L85)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a section saying that web socket configuration is mandatory going forward.

Copy link
Owner

@juanfont juanfont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions...

docs/reverse-proxy.md Outdated Show resolved Hide resolved
docs/reverse-proxy.md Outdated Show resolved Hide resolved
docs/reverse-proxy.md Outdated Show resolved Hide resolved
docs/reverse-proxy.md Outdated Show resolved Hide resolved
juanfont and others added 2 commits September 7, 2022 00:19
Thanks for the pointers!

Co-authored-by: Juan Font <juanfontalonso@gmail.com>
@mike-lloyd03
Copy link
Contributor Author

Thanks for the suggestions.

The only issue I'm still having: Sometimes one of my Linux machines will show that it is offline every few minutes or so. After about a minute it returns to online. I'm not sure why this is only happening on only this machine and not on my Android device or the other two Linux machines I have configured. I'm doubting this has anything to do with the nginx config though.

@mike-lloyd03
Copy link
Contributor Author

mike-lloyd03 commented Sep 6, 2022

Actually it looks like this is also happening on one of the other Linux machines. The VPN connection is still up though so maybe it's not an issue.

@juanfont
Copy link
Owner

Can you run prettier on the .md? The linter is complaining...

@mike-lloyd03
Copy link
Contributor Author

Can you run prettier on the .md? The linter is complaining...

Done.

@juanfont juanfont merged commit c9b39da into juanfont:main Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants