Nginx从 1.1.4 开始,实现了对后端机器的长连接支持,这意味着 Nginx 与后端机器的通信效率更高,后端机器的负担更低。长连接配置示例 upstream http_backend { keepalive 16; server 127.0.0.1:8080; } server { location /http/ { proxy_pass http://http_backend; proxy_http_version 1.1; #设置http版本为1.1 proxy_set_header Connection ""; #设置http头默认为长连接,不关闭 } } 默认使用http1.0,并且connection连接默认是close (即默认是短连接)proxy_set_header Host $proxy_host; proxy_set_header Connection close; 具体参考文章 nginx长连接
Nginx从 1.1.4 开始,实现了对后端机器的长连接支持,这意味着 Nginx 与后端机器的通信效率更高,后端机器的负担更低。
长连接配置示例
默认使用http1.0,并且connection连接默认是close (即默认是短连接)
proxy_set_header Host $proxy_host;
proxy_set_header Connection close;
具体参考文章 nginx长连接