nginx代理后502

直接访问 ​https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions正常

使用nginx代理后访问出现502

    server {
        listen       9999;
        server_name  172.21.3.78;
        location ^~ /compatible-mode {
            proxy_pass https://dashscope.aliyuncs.com;
        }
        location / {
          proxy_pass http://172.21.3.78:9993;
        }
    }

21#21: *5 peer closed connection in SSL handshake (104: Connection reset by peer) while SSL handshaking to upstream, client: 10.10.10.1, server: 172.21.3.78, request: "POST /compatible-mode/v1/chat/completions HTTP/1.1", upstream: "https://47.93.243.29:443/compatible-mode/v1/chat/completions", host: "172.21.3.78:9999"

原因:

在请求时DNS域名进行解析,实际请求出去的是IP与端口,但对方系统是多个域名对应一个公网IP,这个公网IP下映射到了多个项目和服务,通过nginx的server_name进行区分,所以直接请求不通。
 

解决方法:

添加 proxy_ssl_server_name on;

    server {
        listen       9999;
        server_name  172.21.3.78;
        location ^~ /compatible-mode {
            proxy_ssl_server_name on;
            proxy_pass https://dashscope.aliyuncs.com;
        }
        location / {
          proxy_pass http://172.21.3.78:9993;
        }
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值