Tailscale + public domain
from marci@lemmy.world to selfhosted@lemmy.world on 04 Mar 21:53
https://lemmy.world/post/26342457

Hi selfhosting community :)

I am hosting some services on a NixOS box (Immich, Nextcloud and some others). So far I had no problem reaching my services, just via tailscale when I am not at home.

But now I wanted to branch out and get a little fancy with https setup and a domain, so I can share my services with friends. I followed this guide and got a domain at cloudflare. However I ran into some problems.

The relevant setup:

spoiler

Nextcloud: services.nextcloud = { enable = true; hostName = “nextcloud.<mydomain>.com”; https = true; }; Nginx: services.nginx = { enable = true; virtualHosts = { “nextcloud.<mydomain>.com” = { forceSSL = true; useACMEHost = “<mydomain>.com”; }; “immich.<mydomain>.com” = { forceSSL = true; useACMEHost = “<mydomain>.com”; locations.“/”.proxyPass = “http://127.0.0.1:2283”; }; “immich.<machine>.<tailnet>.net” = { locations.“/”.proxyPass = “http://127.0.0.1:2283”; }; }; }; ACME security.acme = { acceptTerms = true; defaults.email = “my@mail.com”; certs.“<mydomain>.com” = { domain = “*.<mydomain>.com”; group = “nginx”; dnsProvider = “cloudflare”; dnsPropagationCheck = true; credentialsFile = config.sops.secrets.cloudflare.path; }; };


My situation now is the following:

Does one of you network wizards know where the problem lies? Or how would I go about troubleshooting the issue?

#selfhosted

threaded - newest

colonelp4nic@lemmy.world on 04 Mar 22:50 next collapse

Right now, I’ve only got the spoons to provide rough guidance, not details. In order to use non-tailnet IPs, you’ll need to configure your tailnet host to “advertise routes/push routes”. In more laymen terms, tailnet needs to say, “hey network client, I do know where 192.168.0.69 is! So I can route that request”. By default, each tailnet host only advertises the other tailnet hosts. Anything else fails.

Also, I really appreciate how detailed your question is!

baduhai@sopuli.xyz on 04 Mar 22:50 next collapse

Have you pointed your DNS record to your tailscale IP? I have the exact setup you describe, and it works fine.

colonelp4nic@lemmy.world on 04 Mar 22:56 next collapse

This approach largely works, with the caveat that it then requires you to always be on the tailnet. If someone wants to connect locally AND via tailnet using the same URL, they’ll need to push/advertise routes (or do some other hacky thing)

baduhai@sopuli.xyz on 04 Mar 23:13 next collapse

Yes, in order to access my domain on my local network, I have my pihole instance point the domain to my server’s local IP.

marci@lemmy.world on 04 Mar 23:49 next collapse

I don’t have a problem to always be on the tailnet with my client devices, but it does not work even for this case.

Asparagus0098@sh.itjust.works on 04 Mar 23:49 collapse

If you run adguard home it’s pretty easy. Just add a DNS rewrite to your local IP.

<img alt="" src="https://sh.itjust.works/pictrs/image/738db046-b252-433e-b651-efc447b4f676.jpeg">

marci@lemmy.world on 04 Mar 23:47 collapse

Yes, similar to the video guide, I set up a wildcard CNAME record to point to <machine>.<tailnet>.net.

baduhai@sopuli.xyz on 05 Mar 01:07 collapse

I see. I dont know if that works, as I haven’t done that, but what worked for me was pointing to the tailnet IP, not the tailnet domain, then disabling expiry for my server on the tailscale dashboard so my IP would stay the same.

Asparagus0098@sh.itjust.works on 04 Mar 23:44 next collapse

How are you running nginx and immich exactly? With containers or on the host?

I don’t know nixos that much but that looks like nixos configuration to me, so it’s running on the host I assume?

marci@lemmy.world on 04 Mar 23:57 collapse

Yes, correct. So far I was able to access the services via <tailscale ip of the host>:<port> on any device in my tailnet.

marci@lemmy.world on 05 Mar 00:42 collapse

I found that the cname record seemed to be the problem. Here someone had the same issue. After changing now to a wildcard A record pointing to the tailscale ip, it all magically works. Thanks for all the answers!