背景
我们的服务会调用外部第三方的服务,第三方服务做了ip白名单限制。出于安全考虑,我们的服务通过Nginx反向代理去访问第三方服务。
之前一直能通过nginx反向代理正常访问到第三方服务接口,昨天突然访问超时,状态码为499
nginx的配置如下:
http {
upstream backend_server {
server example.com:443;
}
server {
...
location /upstream {
proxy_pass https://backend_server/;
}
}
}
查看日志发现是由于未启用SNI导致
2022/01/18 08:41:34 [error] 1031#1031: *3044185 peer closed connection in SSL handshake (104: Connection reset by peer) while SSL handshaking to upstream, client: xxxx server: xxx,
解决办法
修改nginx配置
location /upstream {
proxy_pass https://backend_server/;
proxy_ssl_name example.com;
proxy_ssl_server_name on;
proxy_set_header Connection "";
proxy_set_header Host example.com;
}