Forward port to public IP

1) Log in to your router by entering the gateway ip

Gateway ip / Default route can be found by checking the network settings of the connected netwrok.

2) Find the port forwarding section(varies depending on the router model)

3) Forward port 80 to the local IP of your machine

Port blocking by ISP

1) Sometimes, your ISP might block some port for incomming requests.

For eg, if port 80 was blocked by ISP, you can't foward that port from public IP to LAN

2) To check if a WAN port is blocked, forward a port (disable firewall for that port) and test at www.portchecktool.com

NOTE : Test against LAN ports 80 / 22. It doesn't seems to be working against other LAN ports

TODO : More reliable way to test ISP block

3) If a port is blocked, you can work around this by mapping different WAN port to the required LAN port (Nothing had to be changed in your code)

For eg, set WAN port 81 --> LAN port 80 and access the web page as PUBLIC_IP:WAN_port

When your ISP uses NAT public IP

Sometimes, to overcome shortage of IPv4 address, some ISPs install another router which has a public ip ahead of your home router. That way, a group of people shares the same public IP.

You can find this out by checking the WAN IP in your router account. If WAN IP is different from public IP, your ISP is using a separate NAT router

In this case, you cant forward your port to public IP unless your ISP forwards some port to you

Ask your ISP if they provide you with a separate public IP, If not, request them to forward some random set of ports to your router.

NOTE : Make sure to check the port firewall status in your host machine

Checking your live website

1) Run Django server (make sure to have the domain name in ALLOWED_HOSTS in settings.py)

2) Nginx server config should have a server listening at port 80 and it should proxy to django server

Note:

If default server is not set, nginxs will point all eligibles names (localhost / local ip / public ip) to the server location context. However, if we did not have the allowed host set to ***, django will prevent hosting from other IPs except the provided name in the host.

This can also be resolved at the nginx server by setting a default server with name pointing to domain name

3) Now your website can be accessed from any device with the public URL