我们有:
Ubuntu 16.04
nginx 1.10.3
我是 nginx 新手,需要关于 proxy_pass 到 https 的帮助。
例如,我们在互联网上有客户,他们称之为 url。
https://testapp.mobios.example.com
我想将此流量传递到 IP 地址为 192.168.0.10 的服务器。
在这台服务器上,我启用了 ssl 监听端口 9443。
我们想使用 nginx 作为 reverse_proxy。
我的 nginx 配置看起来像。
server {
listen 443;
servername testapp.mobios.example.com;
location / {
proxy_pass https://192.168.0.10:9443;
}
}
如果客户端尝试使用 https://testapp.mobios.example.com 联系 ssl 服务器他们一无所获。
我需要的只是将 https 传递给 https。 SNI 这里有问题吗?
任何的想法?
请帮忙
阿约拉迪
最佳答案
不是直接相同但相似的问题把我带到了这里。
负载均衡到 HTTPS:
Client <- HTTPS -> (decrypt) Load balancer (encrypt) <- HTTPS -> Server
一般来说,thisisayush 的答案(http://reinout.vanrees.org/weblog/2017/05/02/https-behind-proxy.html)非常好,它部分解决了我的问题,但添加负载平衡会使谷歌搜索变得更加困难。当您制作上游列表时,您必须记住添加
443
港口。不工作:
upstream myapp2 {
server 10.0.1.1;
}
在职的:upstream myapp2 {
server 10.0.1.1:443;
}
即使您在 location
中使用https
协议(protocol)(我希望默认指向 443
):location / {
proxy_pass https://myapp2;
}
完整示例:http {
upstream myapp2 {
server 10.0.1.1:443;
}
server {
listen 443;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
ssl on;
location / {
proxy_pass https://myapp2;
}
}
}
答案基于我最终在 thisisayush 评论的帮助下找到的文档:https://docs.nginx.com/nginx/admin-guide/security-controls/securing-http-traffic-upstream/#complete-example
关于Nginx proxy_pass 到 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51858725/