why does domain name and ip address still show default nginx page but next level url directs to correct django view?

January 8, 2018 122 views
Nginx Django Ubuntu 16.04

after i registered a domain name and tied the domain name to my droplet's ip address, i waited to see if the domain name would be active and show the correct django view which would be called with a url pattern specified as an empty python string ''. shortly after registering the domain name, i used the droplets ip address in the browser as i knew it would take a while for my new domain name to propagate. using just the droplet's ip address correctly called the appropriate django view that is called when the url matches a pattern of an empty python string ''. but later on when i tried typing in my domain name, the default nginx page appeared. then the same thing happened when i tried using the droplets ip address even though it had worked a little earlier. but then when i changed my django projects url.py file to match a more specific url i.e 'stats/' instead of the empty python string '', using the domain name (www.jedistats.com/stats) and the droplets ip address with /stats appended, it worked. why isnt nginx passing the empty url/plain domain name/ip address to the view that's tied to the empty python string '' url pattern?

3 Answers

lol, never mind. i figured out the answer. so i totally forgot that prior to tying a domain name to my droplet, i had already configured/enabled nginx to route to this other django project i was working on but abandoned and i forgot to rm the symlink to that old site. so when i added a new nginx site, the server_name was for an ip address that was also in another conf. and if the url isn't specific enough, i guess nginx will just default to nginx page.

Have another answer? Share your knowledge.