nginx设置请求头Connection为close不生效

后端要求前端使用HTTP1.1版本,并且请求头Connection为close,nginx配置里设置好后不生效
http {
access_log on;
default_type application/octet-stream;
include mime.types;
sendfile on;
keepalive_timeout 0;
client_header_timeout 60;
client_body_timeout 60;
reset_timeout_connection on;
send_timeout 60;
gzip on;
tcp_nopush on;
port_in_redirect off;
sercer_tokens off;

server {
...
location /api{
proxy_pass ...;
proxy_http_version 1.1;
proxy_set_header Connection close;
}
}
}
最后connection依然为keep-alive

img

Http1.1 Keep-Alive默认支持并开启,你发的 Header 是浏览器默认发出的,得看服务端 response header 中响应什么