Nginx反向代理HTTPS出现502 peer closed connection in SSL ..

/ 1评 / 3

今天碰到个奇葩问题,我可以代理Google的HTTPS,不能代理有些网站。

1 peer closed connection in SSL handshake while SSL handshaking to upstream

后台日志爆这个错误。

一开始以为是证书错误什么的。

所以在配置里把SSL证书验证关掉了,结果依然502

proxy_ssl_verify off;

一番无果,又上网查资料。网上大佬说,对于启用SNI 证书部署(PS:一个IP有多个证书)的服务器来说

需要向服务器传递域名信息。也就是需要设置下内容。

proxy_ssl_server_name on;

果然加上一条内容后果然可以正常访问了。

贴个配置,记录下。

  location / {
        if ($request_method = OPTIONS) {
            add_header  Access-Control-Allow-Origin *;
            add_header  Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
            return      204;
        }
    
        resolver              114.114.114.114 8.8.8.8;
        proxy_ssl_server_name on;
        proxy_pass            $scheme://$host:8$server_port$request_uri;
        proxy_ssl_verify off;
        proxy_set_header      X-Real-IP $remote_addr;
        proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header      Upgrade $http_upgrade;
        proxy_set_header      Connection $connection_upgrade;
        client_max_body_size  1m;
    }
  1. Tokin说道:

    你博客证书过期了

发表评论

邮箱地址不会被公开。 必填项已用*标注