Jump to content

I have recently made a web server with nginx on Ubuntu 20.04 where I'm hosting a client's website. I setup port forwarding rules on my network's router for any inbound traffic over tcp/80 to be forwarded to the web server's internal IP.  I use my iPhone and connect over the cellular network to my network's public IP address over port 80. When I connect, it seems to continuously load, and then the URL is changed from my network's public IP to the device's internal IP address. But the page still does not load whatsoever. I have ufw setup to allow traffic over tcp/80. Any ideas? Thanks!

Link to comment
https://linustechtips.com/topic/1327850-nginx-webserver-changing-url/
Share on other sites

Link to post
Share on other sites

1 minute ago, Electronics Wizardy said:

What is this websit? Might be redirecting you to the wrong location.

 

You should really use port 443 and use https.

Hi there, thank you for the response. I haven't registered the domain yet, so I'm just trying to connect to my network's public IP over tcp/80. I was planning on implementing HTTPS, but I'd like to work this out first, as I have the website finished and I'd like to verify that the client likes it. 

Link to post
Share on other sites

10 hours ago, thatmantheman said:

it seems to continuously load, and then the URL is changed from my network's public IP to the device's internal IP address

Does it work internally? Say the web server internal ip is 10.0.0.1, try that on your browser (http://10.0.0.1) on the same machine, and also on a different on in the same WiFI/LAN.

 

If this works the firewall is configured OK, so need to look at port forwarding on your router. Your router should have some settings that will fix the IP address of your machine (if you're using DHCP) so your server always gets the same IP address (10.0.0.1 in this case). There should also be a setting to allow port 80 to be redirected to your machines' internal IP where you can enter port 80 and 10.0.0.1.

 

Now try accessing the site again but don't bother with the phone at first. Use your external IP address (google "what is my ip") at port 80 (e.g. http://80.0.0.1). If you open the chrome developer tools (CTRL + SHIFT + I), on the network tab, turn on "Preserve log" and try and access your site. You should only be seeing requests to resources with the external address.

 

What I suspect is happening is that your port forwarding rules work but there is a redirect on your site that takes you to another page but it's not respecting the hostname accessed by the browser. E.g. http://80.0.0.1/ => http://10.0.0.1/myhomepage. Of course this will work internally, but externally it fails and eventually your phones' browser shows an error on the internal IP.

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×