nginx - 面临 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"
解决方案
只需添加 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;
}
推荐阅读
- macros - IBM XL C/C++ 预处理器宏发生了什么变化?
- php - Href 模态不工作
- node.js - NodeJS 构造自定义对象而不需要文件
- javascript - 在 withTracker 内部使用 ReactiveVar 和 Meteor.call 避免无限循环?
- node.js - 节点 - 节点 HID 未找到设备
- reactjs - 如何在嵌套组件中传递数据?
- java - 查找多维数组的所有垂直遍历
- clojure - 如何编写 Clojure 宏来获取 var 的值?
- javascript - document.getElementById() 无法正常工作
- assembly - 图形重复,程序集引导加载程序