背景
我們的服務(wù)會調(diào)用外部第三方的服務(wù),第三方服務(wù)做了ip白名單限制。出于安全考慮,我們的服務(wù)通過Nginx反向代理去訪問第三方服務(wù)。
之前一直能通過nginx反向代理正常訪問到第三方服務(wù)接口,昨天突然訪問超時,狀態(tài)碼為499
nginx的配置如下:
http {
upstream backend_server {
server example.com:443;
}
server {
...
location /upstream {
proxy_pass https://backend_server/;
}
}
}
查看日志發(fā)現(xiàn)是由于未啟用SNI導(dǎo)致
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;
}