这类似于。唯一的区别是服务器在 80 上监听并转发到 443(配置如下)。

    server {
        listen 80;
        server_name localhost;

        location / {
            proxy_http_version 1.1;

            proxy_pass                 https://112.123.134.145:443;
            proxy_ssl_certificate      /etc/nginx/cert.pem;
            proxy_ssl_certificate_key  /etc/nginx/key.pem;
            proxy_ssl_verify           off;
        }
    }

基本上,当 HTTPS 开启时,即使客户端退出,nginx 似乎仍能与上游保持连接。

一个答案表明,对于 nginx >= 1.5.5,此问题已解决。我有 nginx 1.14.1,但问题仍然存在。

经过进一步研究,错误日志反映的HTTP连接应该被关闭。

2024/10/15 18:28:07 [info] 1429884#0: *3 epoll_wait() reported that client prematurely closed connection, so upstream connection is closed too while reading upstream

但是,HTTPS 仍然保持连接。

1

  • 您没有在此处的配置中明确设置 proxy_ignore_client_abort=off。默认为关闭,但可能在其他地方设置。您如何确定连接未关闭?


    – 


0