Nginx nginx 的 400 错误

simonzg · 2013年03月04日 · 最后由 luikore 回复于 2013年03月04日 · 3987 次阅读

尝试用 unicorn 和 nginx 联合使用,在 localhost 上开启服务,结果 firefox 和 IE 访问都没有问题,但是用 chrome 打开的时候,死活报 400 错误

把 error.log 门槛设置为 info 后,发现类似这么的一条信息: 2013/03/04 09:53:06 [info] 12360#0: *1 client closed prematurely connection while reading client request line, client: 127.0.0.1, server: localhost

百思不得其解,还望高手解惑,顺便贴上 nginx.conf:

user root root;

# Feel free to change all paths to suite your needs here, of course
pid /var/run/nginx.pid;
error_log /var/log/nginx.error.log info;
worker_processes 2;

events {
  worker_connections 1024; # increase if you have lots of clients
  accept_mutex on; # "on" if nginx worker_processes > 1
  use epoll; # enable for Linux 2.6+
  # use kqueue; # enable for FreeBSD, OSX
}

http {
  include mime.types;
  default_type application/octet-stream;
  access_log /var/log/nginx.access.log combined;

  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/xml text/css
             text/comma-separated-values
             text/javascript application/x-javascript
             application/atom+xml;

  upstream app {

    # for UNIX domain socket setups:
    server unix:/tmp/unicorn.sock fail_timeout=0;
  }

  server {
    listen 80 default deferred; # for Linux

    client_max_body_size 4G;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    server_name localhost;

    keepalive_timeout 5;

    root /home/hanz/workspace/watchman/public;

    location ^~ /assets/ {
    root /var/www/;
    autoindex on;
    }

    location / {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header Host $http_host;

      proxy_redirect off;

      proxy_buffering off;

       proxy_pass http://app;
    }

    # Rails error pages
    error_page 500 502 503 504 /500.html;
    location = /500.html {
      root /var/www/;
    }
  }
}

localhost 的 cookie 是否太大了?

需要 登录 后方可回复, 如果你还没有账号请 注册新账号