Nginx 中的 keepalive 分为服务端侧和客户端侧。
服务端侧
upstream http_backend {
server 127.0.0.1:5000;
keepalive 32;
}
server {
...
location / {
proxy_pass http://http_backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
...
}
}
客户端侧
http {
keepalive_timeout 65s;
}