0

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.

  • Tried both a sites-enabled approach as well as a monolithic nginx.conf approach
  • Confirmed that nginx is actually reading my nginx.conf--if I put gibberish in the file, it will refuse to start, complaining about the gibberish
  • Removed the 'default' config in sites-enabled
  • Confirmed that gunicorn started successfully

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.

4

3 に答える 3

1

この記事に基づいて、sendfileディレクティブには virtualbox に関する問題があります。それが役立つかどうかを確認するためにオフにすることができます。

それ以外は、nginx 構成ファイルに問題はありません。ブラウザのキャッシュの問題か、アプリケーションが nginx から渡す必要がある特定のヘッダーまたは Cookie を必要とする可能性があります。

于 2013-04-03T22:43:18.980 に答える
0

だから、これは私自身の行いでした。私が実行していたマシンには、同じポートでローカルに実行されている構成されていないバージョンのnginxがあり(ちょっと怖い...)、リクエストに答えていたことがわかりました。ページを更新するたびに、Vagrant ゲスト マシンではなく、ローカル ホスト マシンから読み込まれていました。手のひら、顔を合わせます。

于 2013-04-04T20:36:22.250 に答える
0

私の場合、ブラウザはキャッシュからサイトを繰り返しロードしていました。ブラウザーの履歴をクリアすると、nginx に新しい構成ファイルが読み込まれました。

于 2014-08-19T07:43:59.033 に答える