0

I set up a Django local server with Nginx, Gunicorn and Ubuntu following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-14-04

I tested it on a local network and worked fine, if I accessed to 192.168.0.101 from any computer on the network I was able to see Nginx default page, and if I entered to 192.168.0.101:8000 I was able to see my Django app, but today I put the server on a new place in a new local network with a new router and tested it again, I entered to the assigned IP 192.168.0.102:8000 and Django app loaded fine but then I tried to access to 192.168.0.102 and the default page was from Apache2 Ubuntu default page instead of Nginx welcome default page, why that happened if my server was working fine with Nginx and Gunicorn?

Also I was able to access to the server using hostname from any computer (Windows, Mac OS X, Mint) without configuring it but now I can access with hostname only over WiFi, trying to access with Ethernet connection can't resolve the hostname.

I hope you can help me and explain why this happened and how to fix it.

techraf
  • 4,243
  • 8
  • 29
  • 44

1 Answers1

0

According to the reference page you mentioned, seems like you have mounted your Nginx service to a single IP address. If you have followed the guide, your current Nginx configuration is as follow:

server {
    listen 80;
    server_name 192.168.0.101;
    ...

Therefore the Nginx service is listening with IP 192.168.0.101 on port 80. But you have a new IP address - 192.168.0.102 so it cannot match.

By default, Apache service will listen on port 80 with all available IP address. So you have got Apache's default page instead of Nginx's one.

After you have changed your Nginx setting to this should work:

server {
    listen 80;
    server_name 192.168.0.102;
    ....

Then, stop the Apache service and restart the Nginx service by:

service httpd stop
service nginx restart

You should be able to see your Nginx webpage again with http://192.168.0.102

Simon MC. Cheng
  • 436
  • 2
  • 7
  • Also, to access from any computer using hostname on the local network, i have to set a DHCP reservation with server mac adress so the other computers can resolve the server hostname instead of accesing with ip? – Kevin Ramirez Zavalza Aug 05 '16 at 02:35
  • For hostname lookup, you need an DNS server and have proper configuration to point the hostname to IP address. Then you need to include your newly installed DNS server via DNS server option under DHCP server to publish it for your client to use. – Simon MC. Cheng Aug 06 '16 at 17:35