Client——>Nginx——>upstream
    Client到Nginx长连接设置(默认长连接)
    Client:http请求头 Connection: “Keep-Alive”
    Nginx:默认长连接,可调整参数keepalive_timeout、keepalive_requests
    keepalive_timeout:默认75s
    keepalive_requests:默认1000
    Nginx到upstream长连接设置(默认短连接)
    Nginx:

    1. http {
    2. upstream SERVER {
    3. server IP:PORT;
    4. keepalive 300;
    5. }
    6. server {
    7. location / {
    8. proxy_pass http:SERVER;
    9. proxy_http_version 1.1;
    10. proxy_set_header Connection "";
    11. }
    12. }

    uwsgi:

    1. http11-socket = :8000
    2. http-keepalive = true

    Client——>Nginx——>uwsgi(application)
    uwsgi_socket_keepalive:Module ngx_http_uwsgi_module (nginx.org)

    实际问题:
    在测试时,我分开查看了tcp连接状态情况

    1. 尽管Client配置了头部connection,但依旧是短连接

    https://www.cnblogs.com/kevingrace/p/9364404.html
    nginx反向代理时如何保持长连接nginx脚本之家
    长连接 · Nginx 学习笔记
    [nginx] 如何设置proxy到upstream的长连接 - toong - 博客园

    客户端进行长连接,服务器仅支持短连接会返回502
    uwsgi支持http长链接 - Small_office - 博客园