mob*_*ios 9 reverse-proxy nginx
我们有: Ubuntu 16.04
nginx 1.10.3
我是 nginx 的新手,需要有关 proxy_pass 到 https 的帮助。
例如,我们在互联网上有客户,他们称之为 url。
https://testapp.mobios.example.com
Run Code Online (Sandbox Code Playgroud)
我想将此流量传递到我的服务器,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;
}
}
Run Code Online (Sandbox Code Playgroud)
如果客户端尝试使用https://testapp.mobios.example.com联系 ssl 服务器,他们将一无所获。
我需要的只是将 https 传递给 https。SNI在这里有问题吗?
任何的想法?请帮助ayyoladi
小智 10
server {
listen 80;
server_name website.domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name website.domain.com;
#Size archive client_max_body_size 50M;
ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/mydomain/chain.pem;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
1 ===> proxy_pass https://website5.domain.ru;
[ OR ]
2 ===> proxy_pass http://192.65.87.4:8020;
}
}
Run Code Online (Sandbox Code Playgroud)
小智 8
不是直接相同但类似的问题把我带到了这里。
负载均衡到 HTTPS:
Client <- HTTPS -> (decrypt) Load balancer (encrypt) <- HTTPS -> Server
Run Code Online (Sandbox Code Playgroud)
一般来说,thisisayush 答案(http://reinout.vanrees.org/weblog/2017/05/02/https-behind-proxy.html)非常好,它部分解决了我的问题,但添加负载平衡使得它变得更加困难谷歌。
当您创建上游列表时,您必须记住添加端口443。
不工作:
upstream myapp2 {
server 10.0.1.1;
}
Run Code Online (Sandbox Code Playgroud)
在职的:
upstream myapp2 {
server 10.0.1.1:443;
}
Run Code Online (Sandbox Code Playgroud)
即使您在location https协议中使用(我希望默认指向443):
location / {
proxy_pass https://myapp2;
}
Run Code Online (Sandbox Code Playgroud)
完整示例:
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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
答案基于我最终在 thisisayush 评论的帮助下找到的文档:
小智 2
我为我的客户做过一次。您要做的就是在 Nginx 中启用并安装 SSL,而不是在被代理的服务器上。
| 归档时间: |
|
| 查看次数: |
29697 次 |
| 最近记录: |