NGINX 代理不断丢失与 uWSGI 后端的连接

NGINX 代理不断丢失与 uWSGI 后端的连接

我有一个 Docker NGINX 主机,用于提供静态网页,并代理到 Docker uWSGI 后端。发生几个错误后,我开始从网站收到 500 错误。查看 NGINX 日志,我看到:

nwm-nginx-1 | 2016-05-04T10:19:07.911553394Z 2016/05/04 10:19:07 [error]
  9#9: *480 upstream sent too big header while reading response header
  from upstream, client: 50.x.x.x, server: , request: "GET /api/data
  HTTP/1.1", upstream: "uwsgi://10.7.0.6:80", host: "server.com", 
  referrer: "https://server.com/"
nwm-nginx-1 | 2016-05-04T10:19:07.911675201Z 50.164.254.84 - - 
  [04/May/2016:10:19:07 +0000] "GET /api/data HTTP/1.1" 502 575 
  "https://server.com/" "Mozilla/5.0 (Windows NT 6.1; WOW64) 
  AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94
  Safari/537.36" "-"

在 uWSGI 日志中:

nwm-api-1 | 2016-05-04T10:19:07.870083229Z [pid: 10|app: 0|req: 97/198]
  50.164.254.84 () {48 vars in 799 bytes} [Wed May  4 06:19:07 2016] 
  POST /api/login => generated 488 bytes in 81 msecs (HTTP/1.1 200) 
  3 headers in 436 bytes (1 switches on core 0)
nwm-api-1 | 2016-05-04T10:19:07.911716856Z Wed May  4 06:19:07 2016 - 
  uwsgi_response_write_body_do(): Connection reset by peer 
  [core/writer.c line 331] during GET /api/data (50.164.254.84)
nwm-api-1 | 2016-05-04T10:19:07.911811097Z IOError: write error

这是我的 NGINX 配置:

gzip on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/css application/x-javascript application/json text/javascript;

uwsgi_buffering off;

server {
  listen 80 default_server;
  return 301 https://$server_name$request_uri;
}

server {
  listen 443 ssl default_server;
  add_header Strict-Transport-Security "max-age=31536000";

  location /api {
    include uwsgi_params;
    uwsgi_pass api:80;
  }

  location / {
    root /web;
  }
}

哪一侧导致问题?我该如何修复?

相关内容