跳到主内容
博客oldsaltfish
博客

nginx反向代理服务状态码502

更新于 2025-07-30 23:20

情况

image

解决

proxy_ssl_server_name on;

conf
    location /proxy/ {
        ...省略
        proxy_ssl_server_name on;
        ...省略
    }

原理

某些 HTTPS 服务依赖 SNI 来识别请求的域名。如果没有设置,可能会返回 502。

curl、浏览器、或 Apifox 等客户端会自动处理 SNI(Server Name Indication),而 Nginx 不会“默认”启用它,这就解释了你为什么代理时会出问题。

评论

正在加载评论