FR: Pull embedded DERP server URL from client request #501

Closed
opened 2025-12-29 02:19:08 +01:00 by adam · 3 comments
Owner

Originally created by @kev-the-dev on GitHub (May 5, 2023).

Feature request
When using the embedded DERP server, it is currently necessary for the config to specify the externally-accessible URL such as:
server_url: http://example.com:8080, as this URL is sent to tailscale clients in the DERPMap, and the clients use this URL to then connect to the DERP server.

However, this requirement complicates the configuration and may be unnecessary. For example, when hosting headscale behind
a reverse proxy a user can host headscale at localhost server_url: http://127.0.0.1:8080 and have the reverse proxy forward to this local endpoint without headscale needing to know the external URL at runtime (which could change, or be dynamic based on deployment environment). However, this will break the embeded DERP server as clients will be sent http://127.0.0.1:8080/derp as the DERP server URL, but this will not be accessible externally.

I propose a feature where the embedded derp server's url reported to a tailscale client will simply mirror the URL from the client's request. For example, if a client requests a derp map at https://example.com:443, headscale will simply return the derp server's url as https://example.com:443/derp. This way headscale does not need to know at runtime what external IP / domain(s) can be used to reach it, or whether it is behind a reverse proxy.

Originally created by @kev-the-dev on GitHub (May 5, 2023). **Feature request** When using the embedded DERP server, it is currently necessary for the config to specify the externally-accessible URL such as: `server_url: http://example.com:8080`, as this URL is sent to tailscale clients in the `DERPMap`, and the clients use this URL to then connect to the DERP server. However, this requirement complicates the configuration and may be unnecessary. For example, when hosting headscale behind a reverse proxy a user can host headscale at localhost `server_url: http://127.0.0.1:8080` and have the reverse proxy forward to this local endpoint without headscale needing to know the external URL at runtime (which could change, or be dynamic based on deployment environment). However, this will break the embeded DERP server as clients will be sent `http://127.0.0.1:8080/derp` as the DERP server URL, but this will not be accessible externally. I propose a feature where the embedded derp server's url reported to a tailscale client will simply mirror the URL from the client's request. For example, if a client requests a derp map at `https://example.com:443`, headscale will simply return the derp server's url as `https://example.com:443/derp`. This way headscale does not need to know at runtime what external IP / domain(s) can be used to reach it, or whether it is behind a reverse proxy.
adam added the enhancementstale labels 2025-12-29 02:19:08 +01:00
adam closed this issue 2025-12-29 02:19:08 +01:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 2, 2023):

This issue is stale because it has been open for 180 days with no activity.

@github-actions[bot] commented on GitHub (Nov 2, 2023): This issue is stale because it has been open for 180 days with no activity.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 16, 2023):

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions[bot] commented on GitHub (Nov 16, 2023): This issue was closed because it has been inactive for 14 days since being marked as stale.
Author
Owner

@Mahaaveer commented on GitHub (Feb 13, 2024):

has anyone found a solution to use the embedded derp server behind a reverse proxy ? i am using traefik.

@Mahaaveer commented on GitHub (Feb 13, 2024): has anyone found a solution to use the embedded derp server behind a reverse proxy ? i am using traefik.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#501