nginx 服务器 proxy_pass 转发 SSL_do_handshake() failed 报错处理
原来的配置是这样的:
server { listen 80; listen 443 ssl; ssl_certificate /etc/nginx/ssl/xxx.com.pem; ssl_certificate_key /etc/nginx/ssl/xxx.com.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; server_name xxx.com; location /alipay/ { proxy_pass https://openapi.alipay.com/; } }
运行后异常报错,查询日志显示 SSL_do_handshake() failed,这种问题是因为同一个IP解析了多个域名证书,默认会使用第一个,所有出现 SSL_do_handshake() failed。
修改后:
server { listen 80; listen 443 ssl; ssl_certificate /etc/nginx/ssl/xxx.com.pem; ssl_certificate_key /etc/nginx/ssl/xxx.com.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; server_name xxx.com; location /alipay/ { proxy_pass https://openapi.alipay.com/; # 增加以下配置 proxy_ssl_server_name on; proxy_ssl_session_reuse off; } }
这样就可以了。
热门文章