85550

nginx always serves welcome page

Question:

I'm trying to make nginx proxy requests to a Django server, but it keeps showing the nginx welcome page.

Here's /etc/nginx/nginx.conf:

worker_processes 4; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile off; tcp_nopush on; keepalive_timeout 65; gzip on; gzip_disable "msie6"; include /etc/nginx/sites-enabled/*; server { listen 8000 default_server; listen [::]:8000 default_server ipv6only=on; } }

and here's /etc/nginx/sites-enabled/dotmanca (the only file in the site-enabled directory):

server { server_name _; access_log off; location /media/ { alias /vagrant/media/; } location /static/ { alias /vagrant/static/; } location / { proxy_pass http://127.0.0.1:8001; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"'; } }

So with no server running on port 8001, I expect a bad gateway error to show up. Instead I see the default "Welcome to nginx!"

Running sudo nginx -t gives the following:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful

Also, sudo service nginx restart appears to do nothing.

My nginx version is 1.4.6, and it's running on Ubuntu Trusty.

Answer1:

So removing the server section from /etc/nginx/nginx.conf and adding the two listen directives to the server section in /etc/nginx/sites-enabled/dotmanca appears to work.

Or at least, it allows sudo nginx -s reload to fix the issue.

Recommend

  • Can I override/extend Meteor methods?
  • nginx configure default error pages
  • Nginx - how to redirect (301) www to non-www correctly for bot http /https?
  • how to redirect http to https in nginx docker elastic beanstalk
  • Calling Handlebars {{render}} with a variable name
  • Indent list items with floating image: problem
  • HTML ordered list indent to keep original numbering
  • jQuery e.stopPropagation() - how to use without breaking dropbox functionality altogether?
  • Dropdown menu items hides behind main menu in bootstrap customized navigation bar
  • keydown event triggered only once
  • ember js subviews and didinsertelement event
  • How to activate JS data-filter when page loads?
  • jQuery-Marquee only working in Firefox
  • acts_as_taggable_on Tags added twice
  • Touch events over two dom elements?
  • JQuery Add class to certain list item
  • Jquery Show & ScrollTop (or ScrollTo)
  • Azure Diagnostic is not saving logs in azure tables
  • Linux command line : edit hacked index files
  • mapping between two ontologies
  • Function JavaScript : on Menu CSS HTML
  • Can't delete li from to-do list
  • Cut the background to expose the layer below
  • Why are YouTube videos using 'youtube.com/v' not loading
  • During installation of Django, why do I keep getting ImportError: No module named django?
  • pillow imaging ImportError
  • Web.config system.webserver errors
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • Checking free space on FTP server
  • Change Inet root folder for iis 7
  • All Classes Conforming to Protocol Inherit Default Implementation
  • Using jQuery closest() method with class selector
  • Updated Ionic CLI but shows previous version (Windows)
  • Websockets service method fails during R startup
  • Jquery - Jquery Wysiwyg return html as a string
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • coudnt use logback because of log4j
  • Observable and ngFor in Angular 2