aravenel
aravenel

Reputation: 348

Nginx - can't get past welcome page using proxy_pass to gunicorn

I am trying to setup nginx to pass to a gunicorn backend to run a Django project. Unfortunately, I cannot seem to get nginx to display anything other than the welcome page, seemingly no matter what I try.

My nginx.conf is as follows:

user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
}

http {
    #include       /etc/nginx/mime.types;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/sites-enabled/*;
}

And in sites-available, I have the file "localhost". This file is then symlinked into sites-enabled.

server {
    listen  80 default_server;
    server_name localhost;
    access_log /srv/www/menus-dev/logs/access.log;
    error_log /srv/www/menus-dev/logs/error.log;
    root    /srv/www/menus-dev/http;

    location / {
        proxy_pass http://127.0.0.1:8888;
    }

    location /static {
        root /srv/www/menus-dev/static_files;
    }
}

Any suggestions? I am banging my head against the wall on this one. Everything tells me this should work just fine, but I just cannot get it running.

This is running on an Ubuntu Precise 32-bit Vagrant VM (virtualbox) for what it's worth.

Upvotes: 0

Views: 1088

Answers (3)

divSivasankaran
divSivasankaran

Reputation: 33

for my case my browser was loading the repeatedly loading my sites from the cache. Once I cleared my browser history, nginx loaded with the new config file.

Upvotes: 0

aravenel
aravenel

Reputation: 348

So, this was my own doing. Turns out the machine I was running on had an unconfigured version of nginx running locally on the same port (kinda scary...), which was thus answering the request. Everytime I refreshed the page, it was loading from the local host machine, not the Vagrant guest machine. Palm, meet face.

Upvotes: 0

Chuan Ma
Chuan Ma

Reputation: 9914

Based on this article, sendfile directive has some issue with virtualbox. You may turn it off to see if it helps.

Other than that, I don't see issue on the nginx config file. Maybe some caching issue in browser, or your application requires some specific headers or cookies that you need to pass on from nginx.

Upvotes: 1

Related Questions