Add support for hosting behind a reverse proxy#125
Add support for hosting behind a reverse proxy#125olistrik wants to merge 5 commits intotailscale:mainfrom
Conversation
| os.Exit(1) | ||
| } | ||
| defer func() { | ||
| ln.Close() // TODO: the other listeners are not closed? |
There was a problem hiding this comment.
I also found this somewhat strange, I'm fairly sure that unix sockets must be closed, but I noticed that none of the tcp listeners are being closed. Are they cleaned up automatically by go when the program exits?
|
|
||
| srv.SetServerURL(strings.TrimSuffix(st.Self.DNSName, "."), *flagPort) | ||
| if *flagServerURL != "" { | ||
| srv.SetServerURL(*flagServerURL, *flagPort) |
There was a problem hiding this comment.
It might be smarter to provide a list of additional TrustedOrigins, that way all the listeners can be supported simultaneously. I'm not very familiar with OAuth2 though, so I didn't want to touch the server.go file in this PR.
| if err := ipn.CheckFunnelAccess(uint16(*flagPort), st.Self); err != nil { | ||
| slog.Error("funnel access denied", slog.Any("error", err)) | ||
|
|
||
| if !*flagDisableTCP { |
There was a problem hiding this comment.
As it stands, I don't really see much of a use-case for --unix-socket without --use-local-tailscaled. The nginx server will never be able to listen on the same domain as tsnet and there will have to be a local tailscaled session for ingress through nginx to be tagged correctly.
I added the disable flag here mostly for completeness.
0b01e40 to
92b2b2d
Compare
Signed-off-by: Oli Strik <strik@olii.nl>
Signed-off-by: Oli Strik <strik@olii.nl>
Signed-off-by: Oli Strik <strik@olii.nl>
Signed-off-by: Oli Strik <strik@olii.nl>
d0dfa55 to
0e573bb
Compare
I needed to do a few things to get this to work, they're in separate commits so if you'd prefer I split them into seperate PRs I can do that quite easily.
--unix-socketflag, which when provided a path will create a socket there and listen on it. This acts much like thelocalhostloopback, but does not elevate the permissions of incoming connections.--disable-tcpflag, this prevents the creation of a TCP listener on eithertsnetortailscaled, but does not otherwise interfere with the creation of the local client.--server-urlflag, which takes precedence over the FQDN of the node. This is used to provide the domain name that the reverse proxy is behind.LISTEN_FDSis provided.I believe this resolves #84, there may be others.
I fully expect this is going to need some discussion, I've tested this on my own server with the following configuration:
I'm not actually using the
--unix-socketflag here, it's not used by the systemd socket listener so it can be dropped if it's deemed unnecessary.