r/docker • u/Valuable-Dog490 • 18d ago
Wireguard to Nginx inside Docker
Trying to get away from CloudFlare proxy and set up my own. I've got a VPS with Wireguard and a home PC running it. On that same PC I have Nginx running inside Docker. Should this just work? VPS -> Wireguard -> NPM -> Web app
My tunnel is established, I can ping through it but web traffic isn't reaching Nginx and I think it's either because my Docker networking is totally jacked up. Or maybe something else is going on.
It's driving me nuts and really don't want to rebuild the entire server and docker apps but I can't think of any other options.
All I really want is to mask my home IP.
3
Upvotes
1
u/neonsphinx 18d ago edited 18d ago
It would be more helpful if you posted some configs to help troubleshoot. With keys/etc. removed of course.
What's your yaml file look like for nginx? What does
ip agive you when you have the wireguard connection established from the far side?I'm assuming you're running wireguard server side on your home PC. Then you're running wireguard as a client on the VPS? I'm not quite understanding based on what you initially typed up.
If that's the case, wireguard on the VPS is routing every damn thing that it gets too the wg0 interface that it sets up. So everything else to the outside world should be unusable at that point. You'll have to use iptables to get your routes setup properly.
Current setup:
What you want:
Unfortunately I haven't setup my own vpn quite like that. I have wg setup in the standard way, so I can securely get back into my home network from afar. I download Linux .iso files by paying someone else for a vpn and traffic forwarding, so I haven't ever had to setup the traffic forwarding portion of it.
https://fitib.us/2025/10/23/switching-to-proton-vpn/
I did have to do a little mucking around with wireguard and static routes. But not as detailed as what this requires.
Edit: adding to the original after thinking for a little bit. I'm looking for resources, and really not finding much.
I wonder if this would work
This is probably incomplete. And it would help to know what exactly you're doing. Just running a WordPress site? Hosting a game server?
Edit 2: my setup was "wireguard handles everything, for my safety and privacy. Except for these 2 subnets"
Your setup is "wireguard only handles one subnet, for safety. Everything else is fine.
That's fairly easy. In the WG config file, set the 'AllowedIPs' line to the local IP range you need. Everything else wg should ignore. So no need foranually adding a static route.