Headscale behind pfSense + HAProxy + Tailscale package

Wanted to have this setup working
Untitled Diagram.drawio

I can only connect to the Headscale control server on my LAN, which is basically pointless for most use cases. The HAProxy part seems to be working (can connect with certs to nginx if i start that on the same port, and can also access the web server that is started with Headscale containing the command you are suppose to run in Headscale to add the machine as a node). The problem is that I am not able to reach the server for login through the public IP. It does work if I open port 80, but not if only 443 is opened. Is this even something that should be possible with Headscale as it is now? In the Headscale config I changed only the listening port, so it should listen to all IPs at that port. Have already learned a lot in investigating this, but hoping for even more insight to networking. Any suggestions would really be appreciated.

I am not sure that Headscale will work with HAProxy, not something I have tested as it has it’s own system for setting up certificates.

I did hope it would be as simple as running Headscale without certs on the homeserver and letting pfSense (Acme + HAProxy) deal with certs. Might do some packet capturing to see if I can get some more info.

I just needed to configure websockets i HAProxy for this to work. Similar to what was disscussed in

https://forum.netgate.com/topic/158983/websockets-configuration-in-haproxy

1 Like

I have a similar setup as you and also have a problem configuring haproxy on my pfsense to handle headscale socket. Have you solved this problem?

I got it working, but cannot remember the details. Moved over to another box and found that a site to site Wireguard setup was better suited for my needs. So I don’t have the configuration anymore. I just followed Tom’s guide on HAProxy and web socket information from the link, and then it worked.

Thanks. I got it working. Cloudflare proxy is the culprit. I have to turn Cloudflare proxy off for my headscale subdomain!

I would post how I made Haproxy support WebSocket that works with my Headscale, just in case others may have had the same difficulty figuring it out.

Frontend

1 Like

Backend

1 Like

@bthoven Thanks for posting this! Helped me a lot.

1 Like