首页 > 解决方案 > 面临 nginx proxy_pass 的问题

问题描述

我想以 https://atmvpn.appdomain.cloud/sft-ui/sft/api/orgs/v1/org这样的方式 做proxy_pass,https://dev.apnat.net/sft/api/orgs/v1/org而proxy_pass我们需要删除sft-ui所以我在nginx.conf文件中添加下面的位置

`location /sft-ui/sft/api {
      access_log off;
      rewrite ^/sft-ui/(.*)  /$1 break;
      proxy_pass <%= ENV["AMS_DOMAIN"] %>;
    }`

我已将AMS_DOMAIN设置为环境变量。但是当我https://atmvpn.appdomain.cloud/sft-ui/sft/api/orgs/v1/org在浏览器中点击时,我收到错误“502 Bad Gateway”。

在 openshift pod 的日志中,我可以看到:

2020/06/05 07:06:46 [error] 11#11: *1 SSL_do_handshake() failed (SSL: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:SSL alert number 40) while SSL handshaking to upstream, client: 172.30.96.141, server: , request: "GET /sft-ui/sft/api/orgs/v1/org HTTP/1.1", upstream: "https://104.18.12.180:443/sft/api/orgs/v1/org", host: "atmvpn.appdomain.cloud"

2020/06/05 07:06:46 [warn] 11#11: *1 upstream server temporarily disabled while SSL handshaking to upstream, client: 172.30.96.141, server: , request: "GET /sft-ui/sft/api/orgs/v1/org HTTP/1.1", upstream: "https://104.18.12.180:443/sft/api/orgs/v1/org", host: "atmvpn.appdomain.cloud"

标签: nginx

解决方案


只需添加 proxy_ssl_server_name ;它解决了

 location /sft-ui/sft/api {
          access_log off;
          rewrite ^/sft-ui/(.*)  /$1 break;
          proxy_pass <%= ENV["AMS_DOMAIN"] %>;
          #By setting to "on" can proxy to upstream hosts using SNI
          proxy_ssl_server_name on;
        }

推荐阅读