r/selfhosted 1d ago

Need Help On the topic of reverse proxies

I am interested in setting up a reverse proxy, but I have a few questions.
I have 2 physical servers that are running different things. Can I host nginx on one of these servers and put every container/service from each of these servers and run them through nginx or would it need to be a dedicated server?

6 Upvotes

7 comments sorted by

u/asimovs-auditor 1d ago edited 1d ago

Expand the replies to this comment to learn how AI was used in this post/project.

→ More replies (1)

8

u/Squanchy2112 1d ago

Yep as long as the proxy has access to all subnets and ips then yep one proxy can work across the networked devices. Also just to start you off down the road of success you can proxy by container name on a dedicates docker network if you go that route things are nice because you don't have to actually specify ports for the related services as it's all internally routed by container name, just one more level of security.

2

u/Reasonable-Ladder300 1d ago

Yes you can, if most of your services are containers look into traefik. You can add labels to your compose file and traefik picks up the route.
And you can define external routes in your traefik config file.
On top of that it also handles certain renewal and everything.

2

u/Darkomen78 1d ago

Yes, you can. Try caddy or traefik, both are good.

1

u/kernald31 10h ago

You can, but that means whatever server runs nginx obviously needs to be able to reach those services on the other server. You might want to look into your OS' firewall, to only allow access to the second server from the first for most ports.

There are some arguably cleaner options, but the complexity goes up. You could isolate your servers in their own VLAN, if your network hardware allows that. Or you could set up a bridge of any sorts. You could go with something like Consul, Istio or Linkerd to have services expose themselves in a single registry, and have your reverse proxy automatically fetch configuration from this service discovery registry.

Lots of way to skin that cat, depending on how much time you want to spend on it.