EDIT: Thanks for the info guys! Very excited to get this all set up

At the moment I have a bunch of self-hosting services hosted in the cloud. I plan to get rid of my cloud resources entirely and run stuff on some server hardware I acquired recently but my ISP doesn’t give me a static IP and I’m behind a NAT or whatever it’s called (the thing that makes multiple people’s home connections be behind a single public IP) so I don’t think I can even expose directly to the internet. So my plan is to have a very small and cheap server at a data center and proxy my actual server behind that.

My question is, is there a way that I can set things up so that the same domain can connect directly to the server when I’m at home, and to the proxy when I’m not? The difference would be what connection I’m connected to (my home WiFi vs 5G/others’ WiFi). I’m thinking I could maybe run DNS on the server and configure my router to use that as a DNS server, but wouldn’t my phone/laptop cache DNS entries? So it’d still try to connect to the local IP even when I’m out.

  • Osayidan
    link
    fedilink
    English
    31 year ago

    Very possible and done all the time.

    At home you run a local DNS server, plenty of options out there especially as a self-hoster: bind, power dns, microsoft DNS if you’re into windows. you can also combine this with something like pihole to block ads and junk at the dns level.

    You create the dns zone on your dns server, internal devices use that dns server. You create the same zone on a public DNS provider like cloudflare or whoever (or host your own if you feel like it, on your vps), with public IPs.

    Any of your devices coming/going from your home should be using DHCP to obtain an IP. At home your DHCP settings would hand out the local DNS server, anywhere else you go you’ll be using other DNS servers that will resolve the public IP. It should all be pretty seamless and transparent once set up.