Client——>Nginx——>upstream
Client到Nginx长连接设置(默认长连接)
Client:http请求头 Connection: “Keep-Alive”
Nginx:默认长连接,可调整参数keepalive_timeout、keepalive_requests
keepalive_timeout:默认75s
keepalive_requests:默认1000
Nginx到upstream长连接设置(默认短连接)
Nginx:
http {
upstream SERVER {
server IP:PORT;
keepalive 300;
}
server {
location / {
proxy_pass http:SERVER;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}
uwsgi:
http11-socket = :8000
http-keepalive = true
Client——>Nginx——>uwsgi(application)
uwsgi_socket_keepalive:Module ngx_http_uwsgi_module (nginx.org)
实际问题:
在测试时,我分开查看了tcp连接状态情况
- 尽管Client配置了头部connection,但依旧是短连接
https://www.cnblogs.com/kevingrace/p/9364404.html
nginx反向代理时如何保持长连接nginx脚本之家
长连接 · Nginx 学习笔记
[nginx] 如何设置proxy到upstream的长连接 - toong - 博客园
客户端进行长连接,服务器仅支持短连接会返回502
uwsgi支持http长链接 - Small_office - 博客园