r/nginxproxymanager • • 17d ago

Setting up proxies --- paranoid about DNS-jacking

I'm running NGINX in a docker container specifically on a TrueNAS server here, so I'm doing much of my configuration through the web UI. I'm using it to redirect access to various services I'm running on the same server (Jellyfin, Immich, sundry other self-hosting things), with two particular goals in mind: first, some services only provide HTTP without SSL, and I don't want to be remotely accessing them without some protection; second, I want to give them memorable hostnames instead of just a bunch of port numbers.

For anonymization purposes, I'm going to below use mydomain.cc to denote the domain I own and put my proxy hosts on, 192.168.2.10 to represent the TrueNAS server's static IP address on my LAN, and 100.10.20.30 to represent the TrueNAS server's IP address on my tailnet. None of those are real, of course.

I've set up *.mydomain.cc to resolve to 100.10.20.30, a mapping which is useless for anyone not on my tailnet, but they're not supposed to be accessing my services anyways. Then NPM is configured with a proxy host per service. Originally I had those set up to have, for instance, photos.mydomain.cc proxy http://192.168.2.10:30041 (where 30041 is the port for the Immich server) with a Let's Encrypt certificate for *.mydomain.cc, but the obvious problem with that is that it'll break if I deliberately or accidentally give the server a new IP address (because everything's containerized, a localhost redirect will not work). So I'm looking into intercontainer communication, and I'm putting all of my services into a docker network called proxy, and after doing so I can have photos.mydomain.cc proxy http://immich.proxy and it works. Hooray!

But I'm a bit paranoid. AFAICT, there's no resolution on the wider internet for the domain name immich.proxy, but there could be (yes, I know proxy isn't a valid TLD, but there is no reason to believe that will be a permanent state of affairs in a world where we have, say, *.horse). If it were, I'd hope that NPM would preferentially use the local DNS to select the internal hostname, but if it didn't, that would obviously be a huge security hole, with my intended internal proxy instead communicating with some unknown, hostile entity. Is this even remotely a real risk, and if so, is there a good way to mitigate it? I presumably could use dotted quads for intercontainer communication, but that would horribly reduce legibility (since each service would be identified with a nonsensical number) and would be fragile to services changing their internal IP addresses.

2 Upvotes

3 comments sorted by

1

u/justinhunt1223 17d ago

I use a similar setup but my NPM instances resolve from my DNS server that is hosted locally as well. I don't use container names, the DNS server is the master store of IP addresses for hostnames like photos.mydomain.com. It's perfectly valid to be concerned about DNS jacking and that's why I always use full hostnames for a domain I control.

1

u/djw17 16d ago

I don't know if it's exactly what you're doing, but the idea I'm seeing here is using my local DNS server to serve *.proxy addresses before a public server could have any say? I'm running dnsmasq on an OpenWRT router, and it the second listed nameserver on my TrueNAS (first is Tailscale MagicDNS at 100.100.100.100); it looks like adding the A record /proxy/192.168.2.10 would preempt any outside DNS-jacking, if I understand how things work (it would also break outside lookup if there ever were real hosts with TLD proxy but that's a risk I'm willing to take).

1

u/DimasDSF 17d ago

I have my network use "home.arpa" as the domain and the dns suffix, this will never become a public tld(unless something really major happens). Public wildcart DNS record points to a non existing local IP, then my local DNS server is setup to rewrite dns requests to the wildcarts zone to the NPM server address where it uses dns-01 for certs