0

我有一个运行 nginx、django 1.5、gunicorn 的应用程序。

场景 1 当我一次加载我的应用程序时 - 它会显示带有底层 200 HTTP 响应的页面文件。

方案 2

但是,如果我在此之后立即重新加载同一页面,它将显示我的 HTTP 500 默认但自定义页面。

场景 X 如果我再次重新加载,它将在后续页面重新加载时显示场景 1 或场景 2。

我查看了我的 nginx 的 access.log 和...

它显示了 500 错误页面的信息:

[05/Oct/2013:03:26:07 +0000] "GET / HTTP/1.1" 500 460 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0"

 [05/Oct/2013:03:21:19 +0000] "GET /static/img/templated/base/subnav_back.png HTTP/1.1" 304 0 "http://mydomain.com/static/css/base.css" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0"

它显示 200 HTTP 响应的信息:

[05/Oct/2013:03:18:25 +0000] "GET /static/img/templated/base/subnav_back.png HTTP/1.1" 200 7674 "http://mydomain.com/static/css/mysite_base.css" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0"

nginx conf 看起来像:

server {
        server_name ec2-X-X-X-X.compute-1.amazonaws.com;
        access_log /home/ubuntu/virtualenv/mysite/error/access.log;
        error_log /home/ubuntu/virtualenv/mysite/error/error.log warn;
        connection_pool_size 2048;

        root /home/ubuntu/virtualenv/mysite/homelaunch/;

        location /static/ {
            alias /home/ubuntu/virtualenv/mysite/homelaunch/static/;
            #alias /static/;
            #root /home/ubuntu/virtualenv/mysite/homelaunch/;
        }

        location / {
            proxy_pass http://127.0.0.1:8001;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            #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"';
        }
    }

error.log 有:

2013/09/21 19:36:22 [error] 12680#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: XX.XXX.XX.XXX, server: ec2-x-x-x-x.compute-1.amazonaws.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8001/", host: "www.mysite.com", referrer: "http://www.mysite.com/dir/"
4

0 回答 0