【发布时间】:2019-08-24 07:10:44
【问题描述】:
我的设置是一个负载均衡器,它连接到一个 nginx 盒子,它充当位于 uwsgi 应用程序前面的负载均衡器的反向代理。
我得到一个零星的 502 和不少
epoll_wait() reported that client prematurely closed connection
查看 uwsgi 应用程序前面的 ALB 日志,response_processing_time 字段设置为-1。我已经测试过绕过 nginx 并直接到 ALB 与 uwsgi 应用程序对话运行良好,因此 nginx 方面的某些东西正在中断。
我查看了几十个解决方案,以下是我尝试过的主要解决方案,但没有成功
- 尝试关闭 keepalive
- 尝试增加保活超时
- 确保它在 http1.1 上
- 代理读取/连接超时增加
- 升级到 Nginx 1.17.3
- 增加 ulimit、somaxconn 等
-
在 location 中设置很多标题和设置
location @uwsgi { proxy_http_version 1.1; proxy_set_header Connection ""; proxy_cache_key sfs$request_uri$scheme; proxy_pass $uwsgi_django_backend; proxy_set_header X-NginX-Proxy true; proxy_set_header Connection ""; proxy_set_header X-Request-Start "t=${msec}000"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }
我尝试删除 uwsgi ALB 并直接进入单个 UWSGI 应用程序。 502 消失了。显然,随着我的扩展,这不会起作用。
有没有人知道为什么 ALB 给了我不好的回应?
【问题讨论】:
标签: amazon-web-services nginx uwsgi amazon-elb aws-application-load-balancer