我有一个Django的应用程序,它在Django的服务器上工作正常。 我只是configuration它与nginx和gunicorn。 除了其中一个外,几乎每个页面都可以正常工作。 这是一个非常大的页面,它由4个select(下拉)菜单组成,每个菜单1000个条目,每个菜单由guinicorn单个html文件发送。 Gunicorn只显示页面的一半。 有趣的是,没有nginx,gunicorn显示整个事情就好了。 尽pipe生成的页面不是静态的,但由于某种原因,nginx会中断页面。
这是我的nginxconfiguration:
ec2-user@ip-172-31-44-39:~/mira_website> sudo cat /etc/nginx/sites-available/miraFrontEnd # This is example contains the bare minimum to get nginx going with # Gunicornservers. worker_processes 1; user ec2-user nogroup; # for systems with a "nogroup" # user nobody nobody; # for systems with "nobody" as a group instead # Feel free to change all paths to suit your needs here, of course pid /tmp/nginx.pid; error_log /tmp/nginx.error.log; events { worker_connections 1024; # increase if you have lots of clients accept_mutex off; # "on" if nginx worker_processes > 1 # use epoll; # enable for Linux 2.6+ # use kqueue; # enable for FreeBSD, OSX } http { # nginx will find this file in the config directory set at nginx build time # include mime.types; # fallback in case we can't determine a type default_type application/octet-stream; # click tracking! access_log /tmp/nginx.access.log combined; # you generally want to serve static files with nginx since neither # Unicorn nor Rainbows! is optimized for it at the moment sendfile on; tcp_nopush on; # off may be better for *some* Comet/long-poll stuff tcp_nodelay off; # on may be better for some Comet/long-poll stuff gzip on; gzip_http_version 1.0; gzip_proxied any; gzip_min_length 500; gzip_disable "MSIE [1-6]\."; gzip_types text/plain text/html text/xml text/css text/comma-separated-values text/javascript application/x-javascript application/atom+xml; upstream app_server { # for UNIX domain socket setups: server unix:/home/ec2-user/gunicorn.sock fail_timeout=0; # for TCP setups, point these to your backend servers # server 192.168.0.7:8080 fail_timeout=0; # server 192.168.0.8:8080 fail_timeout=0; # server 192.168.0.9:8080 fail_timeout=0; } server { # listen 80 default deferred; # for Linux # listen 80 default accept_filter=httpready; # for FreeBSD listen 8000; client_max_body_size 4G; server_name _; keepalive_timeout 10; location /static { autoindex on; alias /home/ec2-user/mira_website/manageDb/static/; } location / { # checks for static file, if not found proxy to app try_files $uri @proxy_to_app; } location @proxy_to_app { # an HTTP header important enough to have its own Wikipedia entry: # http://en.wikipedia.org/wiki/X-Forwarded-For proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # enable this if and only if you use HTTPS, this helps Rack # set the proper protocol for doing redirects: # proxy_set_header X-Forwarded-Proto https; # pass the Host: header from the client right along so redirects # can be set properly within the Rack application proxy_set_header Host $http_host; # we don't want nginx trying to do something clever with # redirects, we set the Host: header above already. proxy_redirect off; proxy_pass http://app_server; } # Error pages error_page 500 502 503 504 /500.html; location = /500.html { root /path/to/app/current/public; } } }
这台服务器运行在亚马逊ec2与Suse Linux。
有任何想法吗?
编辑:好吧,这是有趣的,我清除浏览器的caching,历史,cookies和一切,它开始工作。 然后,在几分钟后再次尝试,它有同样的问题。 所以看来,当我清除caching,它开始工作,但只有一段时间(怪异!)。
我已经尝试了很多不同的configuration,并得到它的工作,但我不知道什么是真正的情况。 我认为的是,这个叫做proxy_buffering的指令。 它现在被设置为off 。
此外,什么可以解决这个问题是设置proxy_buffer_size size 。 这里是关于这个指令的官方文档。