How to access nginx web site from internal and external IP's? reddit / selfhosted ---------------------------------------------------------------------- SpreadHateNotLove · 2023-11-06 18:44 Hey! Recently I've bought an old server and started hosting apps/services myself, and one thing I am hosting is my own website (why pay hosting company when I have a machine running anyway, eh? :D). So, I ran into an issue, where I can access website from outside the network, but not from inside. Which is fine, but is there a trick to access same website from inside the network? Current setup looks something like this: Domain pointed to my ip, then ports 80 and 443 are forwarded to nginx proxy manager which forwards them to nginx webserver. So, is there any way to access that same website from inside the network? Thanks! ---------------------------------------------------------------------- jerwong · 2023-11-06 18:55 There are two ways to deal with this: 1. On your DNS server, return local IPs for local machines and let your external clients receive the public IP from the outside world. 2. Set up something called a hairpin route on your router. It essentially NATs it back to your inside network. Note that not all routers support this. ---------------------------------------------------------------------- ElevenNotes · 2023-11-06 18:56 Split DNS. Resolve domain.com to the IP of your NPM. ---------------------------------------------------------------------- SpreadHateNotLove · 2023-11-06 19:49 THIS HELPED ME A LOT! I think I tried a similar thing, but I tried routing directly from DNS to a web server, which resulted in this not working, I did not think of routing to NPM and then to the server. Thanks! ---------------------------------------------------------------------- SpreadHateNotLove · 2023-11-06 19:51 Thank you! Found the solution in the u/ElevenNotes comment below, which is basically what you mentioned in your first point. The second option is definitely not possible on my router (it doesn't even care if I change the DNS setting, let alone having any advanced features). ---------------------------------------------------------------------- SpreadHateNotLove · 2023-11-06 20:03 Also, for everyone else who might encounter this issue. Don't forget to clear the DNS cache (if using Chrome, disable Async DNS resolver as it actually looks like it checks multiple DNS servers). ---------------------------------------------------------------------- ElevenNotes · 2023-11-06 21:44 You're welcome! ---------------------------------------------------------------------- ElevenNotes · 2023-11-06 21:45 Hairpin NAT is messy, avoid it, even if its an available option. Split DNS! ---------------------------------------------------------------------- EriksonEnterprises · 2023-11-07 11:03 Careful with hosting on your own though, some ISPs highly discourage it and you also risk people figuring out your direct home IP which can open another can of worms (direct attacks and whatnot) I recommend setting up cloudflare at a minimum if you desire to still do that :) ---------------------------------------------------------------------- SpreadHateNotLove · 2023-11-07 11:48 Thanks for notifying me. I am currently only hosting a portfolio website, a super lightweight website without much of things to do in it. Nothing comercial. But either way, I will still check it out :) As for ISP, as far as I know, my ISP doesn't really care about it. With my current internet plan, I would not be able to host anything that gets too much traffic. My current network connection is 95mbps down and 30-40 up, and it's on a good day (hybrid DSL connection with 4G antenna). It's more to save a couple of bucks for my portfolio website. If I ever want to have anything that needs actual uptime and stability I will definitely choose a provider over hosting at home :D ---------------------------------------------------------------------- EriksonEnterprises · 2023-11-07 12:06 You'd be surprised. There's a lot of automatic attacks. My brand new server brand new IP address got malware within a day (I installed the system and left it until the next day to setup). I also remember when I was younger doing similar things, I had a server through my ISP, and all my computers on my network were getting hit with so many log files of outside attempts to access... Cloudflare will protect a lot of that, to some extent... Also I would read the terms and conditions of the ISP, unfortunately there's likely something there. If they let you host your plan would be much more expensive even if you're not using it... Just like how you can use your phones hotspot, but once you start using it against the terms (like tethering or whatever), you get cancelled lol Just some advisements :) everyone has their own choices to make haha. Make sure everything is secure like your Apache config, MySQL config, computer security/ports/etc ---------------------------------------------------------------------- EriksonEnterprises · 2023-11-07 12:50 Oh also, lots of ISPs don't assign static IP addresses, so your IP will randomly change at some point and you'll have to update your IP with your domain name service fairly often (depending on their policies). Just letting you know so your prepared :) ---------------------------------------------------------------------- SpreadHateNotLove · 2023-11-07 21:25 Thanks for the heads up! Actually, might as well spend a couple of euros for hosting if I will need it badly, for now, it seems like it's not actually needed too much. As for the ISP, have read the terms, and did not see anything regarding hosting at home... I don't think it's really cost-effective for people to host huge projects/servers inside their homes because of electricity, I've seen entry-level VPSs go for a couple of euros a month, sometimes even less. But, I'm in the process of changing my plan to 5G, because of the greater speeds that are achievable in my area, though data is unlimited, there might be additional rules in the contract. Either way, my main focus is small game servers for friends + NAS for file/security camera storage. So the traffic from outside, won't be noticeable.