Nginx proxy_pass 到 https

标签 nginx reverse-proxy

我们有:
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/

相关文章:

ruby-on-rails - execjs - 找不到 JavaScript 运行时

docker - 托管服务器返回 localhost/web

html - 外部 css 在本地主机上工作正常但在远程服务器上不工作

wordpress - 反向代理 heroku 应用程序到 WordPress 博客

ssl - 将安全 https 代理到不受信任的 https 站点

java - 将请求传递给正确的应用程序

django - nginx子域和域重写w代理pass

node.js - nGinx 反向代理解决 Node.js 问题

nginx - 在Kubernetes NGINX反向代理入口 Controller 中按路径重写

Azure Functions 代理 - 路由到存储帐户