小敏同学嗷 2022-09-19 19:13 采纳率: 0%
浏览 50

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

  • 写回答

1条回答 默认 最新

  • yt_php 2022-09-19 19:30
    关注

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

    评论

报告相同问题?

问题事件

  • 创建了问题 9月19日