A question about remote access of self hosted services (cloudflare, nginx, tailscale)

Remote Access

I'll start with the short story. I've been banging my head over this for the past week, without really coming closer to understanding how should I approach this. I've tried using nginx, tailscale, cloudflare, and random mixes of these. I tried, but couldn't find anything super comprehensible to follow or learn along.

in the end, what I wanted to achieve with this is to at least get a working link between my cloudflare domain and my jellyfin server. However, I did read about the TOS restrictions and read many people suggesting the use of a reverse proxy, nginx.

This week I'll be porting everything to a NAS, so at least as far as I've understood, tailscale would be a good solution to avoid port forwarding and annihilating the security of the network here.

Now comes today, where I still have no idea how I should tackle this, in what order, etc...

Any help is very much appreciated.

Posted Apr 14, 2023, 8:06 PM UTC

222

Strangely unclear from your post if you're trying to VPN into your LAN to access services, or if you actually want to expose services to the internet on a domain protected by SSL.

If the latter, Synology NAS actually comes with free subdomain, dynamic DNS, and SSL certificate support built in, and you would want to use the "reverse proxy" feature to expose selfhosted services. Remember to forward the relevant ports on your router also.

4
DevonDekhranOP•

Yeah, I had some issues sorting out what I was thinking in the comments below, but I sort of understood what I was really failing at. About the nas, it's asustor, so I dunno if it also supports those features you said

1

Synology's reverse proxy can also be used to point to other devices on your network if it helps.

1
SandboChang•

It’s pretty unclear from your description, but I take it as you want WAN side to access a server you have in your home LAN network.

One way to do so, which I did as I don’t have IPv4 address at home, is to

  1. Set up a WireGuard connection between the server and a VPS such as an AWS server
  2. Once the above is done, set up a reverse proxy service in your VPS. What it will do is redirecting an access to the VPS to the WireGuard connected server.

So when a client wants to access your server, the client will try to connect to the VPS’s IP at a port you set. Once the client has reached the VPS, the client will then reach directly your home server. The client will not even be aware that you are running a reverse proxy, they will think they are browsing a website or connecting to a server at the VPS’s IP.

Another option will be to use Tailscale.

3
ziofagnano•

Can you summarize what you want to do? I could not understand that reading your comment.

Examples:

  • I have a Jellyfin server at home. I'd like to be able to access it from my laptop or phone, at any time.

  • I have a Jellyfin server at home. I wish to make it accessible to anyone with an Internet connection, as long as they have login and password.

2
DevonDekhranOP•

Both, sort of. I want to link my server to my cloudflare domain, and use that with a reverse proxy as to not violate their TOS.

So it would be on the internet, password protected

1
ziofagnano•

I suggest you try very hard to clarify:

  • What you have at your disposal
  • What you want to achieve

and, while clarifying these, you leave out the "what your current plan is". You can include that, but as a third part. Or maybe I'm not understanding but somebody else will and answer your question. But I have a hunch your question is hard to answer because it doesn't clarify enough the two points above.

3
DevonDekhranOP•

Very well, I'm very new to this servers and all.

I have a cloudflare domain, a windows pc (later a NAS), the jellyfin server at home, good enough internet, and I don't really know what else you would mean by having at my disposal. docker?

What I wanted to do was to access my jellyfin server, wherever I am, using that cloudflare domain, instead of a VPN or similar.

Hope it actually made it more understandable

Edit: As int he comment below, I think my issue might stand on my inability to understand my router's port-forwarding scheme. Which is sad, since even the manual is fairly useless in explaining the very shortened UI it has

1
H_Q_•

You are mixing up concepts and tools.

If you want public-facing Jellyfin, it can be achieved with as little as an open port on your router and a CF DNS entry pointing your domain to your IP. CF have no limits on that.

Now, this is VERY risky. That's why people add other things to the chain but certainly not all of them at the same time.

The rate-limiting you are talking about is on CF Tunnels. CF Tunnels connect your services to the CF proxy. It hides your real IP, has nice protection and you can add middlewares like authentication, rewrites and so on. But it won't allow media content.

Luckily, you can host your own reverse proxy that sits in front of Jellyfin and adds authentication. Point CF DNS to your IP, forward port 443 on your router to your server. Set up a reverse proxy on you server that listens on port 443 and sends requests to your jellyfin service. Modern reverse proxies have "middlewares" that add functionality like authentication, rewites, etc. This has no restrictions by CF.

This is slightly more secure as you are exposing only your reverse proxy / login portal to the public. But if they have an unpatched vulnerability and someone breaks in... 💀

Tailscale comes into the mix if you want to create a private network that is accessible only by authorized clients. You can still put a reverse proxy between the jellyfin service and the tailnet. You can still point CF DNS to your tailnet IP. But the only way to reach anything in the tailnet would be as a member of that tailnet. Since it's not a public network. This has no restrictions by CF either.

So, there are many ways to set things up. Each with their pros and cons. You just have to know what you want precisely. Which is harder than it seems.

1
zfa•

Just to clarify for others reading your excellent reply - it isn't Cloudflare Tunnels per se that precludes the video streaming per S2.8 of the CF TOS. It is routing that traffic through them PERIOD.

So if you just a the DNS entry per your paragraph 1 you need to 'grey cloud' it. Obviously you can't 'grey cloud' Cloudflare Tunnels so that's out, as you say.

2
H_Q_•

Correct. If you are streaming through the CF Proxy (orange cloud) you are violating TOS. And since tunnels use the CF Proxy by design, you can't use them for streaming. Using just the CF DNS (grey cloud), has no limitations.

That being said, CF have soft caps on these things so unless you are purposefully abusing their services for multimedia streaming, they won't raise any issues. For example, hosting a small video on your self-hosted blog probably won't be a problem.

2
DevonDekhranOP•

Luckily, you can host your own reverse proxy that sits in front of
Jellyfin and adds authentication. Point CF DNS to your IP, forward port
443 on your router to your server. Set up a reverse proxy on you server
that listens on port 443 and sends requests to your jellyfin service.
Modern reverse proxies have "middlewares" that add functionality like
authentication, rewites, etc. This has no restrictions by CF.

This is exactly what I want to achieve, but it's going way over my head. My router seems useless in the port-forwarding part, as in it's a terrible interface with no useful explanation on what it's trying to say.

So I guess it might actually be an issue with me being unable to correctly port forward?

1
H_Q_•

Dunno, I can't comment on port-forwarding. There are tools that check for open ports, if services are reachable, etc.

My advice is to set up a reverse proxy first. Make sure you can reach Jellyfin through it, locally. If you are gonna be exposing stuff, you should be working with https (:443) instead of http (:80). Then work on port-forwarding <public ip>:443 to <local server ip>:443. I can't provide more help than this without knowing your stack.

IMO, if you are struggling with these concepts, you should not be exposing stuff to the internet. It might be very cool. But it's risky AF since you don't know what you are doing. I can give you a step-by-step guide and you might still mess up somewhere and open a hole for anyone to peek through. My advice is to stick to tailscale or plain wireguard. Keep things hidden and private.

1
hijinko•

You don't tell us too much about your setup but the way I do it is by using haproxy on pfsense. You do need a domain though. Plenty of tutorials on YouTube from Lawrence Systems.

2
Abiding5037•

Use your cloudflare DNS to create an A record of your domain to point to the local tailscale IP of the machine your are hosting your services and any CNAME record for the subdomains your want to use. Then use nginx to point the domain name to your local services. You will only be able to access your services while connected to your tailnet.

2
batboy29011•

Not OP, this is what I did and I don't regret it for a second. It's pretty simple to share with friends as well for access.

You could also set up a wildcard domain in Cloudflare to make things a bit easier for subdomaining.

1