nginx:转发到另一台服务器的ssl连接

J J*_*J J 7 ssl https nginx forward

我有一个主nginx服务器决定传入服务器名称将请求路由到哪里.对于两个辅助服务器,此主nginx服务器也持有ssl证书和密钥.第三台服务器持有自己的证书和密钥,因为它们经常有更新过程.

我现在的问题是如何配置主nginx服务器以将所有请求转发到服务器3,这些请求将进入此服务器.我无法将证书和密钥从服务器3复制到主服务器,因为它们经常更改.

概述服务器和http(s)连接

小智 7

尝试代理 tcp 流量而不是 http 流量

stream {
    server {
        listen SRC_IP:SRC_PORT;
        proxy_pass DST_IP:DST_PORT;
   }
}
Run Code Online (Sandbox Code Playgroud)

有关更多详细信息,请参阅 nginx 文档 https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/


wol*_*mer 5

这是一个可能有效的配置。通过master进行代理并将所有内容转发到Server3。使用 ssl 端口但关闭 ssl。

\n\n
server {\n    listen      443;\n    server_name  myserver.mydomain.whatever;\n\n    ssl         off;\n\n    access_log      /var/log/nginx/myserver.access.log;\n    error_log       /var/log/nginx/myserver.error.og;\n\n    keepalive_timeout   60;\n\n    location / {\n        set $fixed_destination $http_destination;\n        if ( $http_destination ~* ^https(.*)$ )\n        {\n            set $fixed_destination http$1;\n        }\n\n        proxy_set_header        Host $host;\n        proxy_set_header        X-Real-IP $remote_addr;\n        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header        X-Forwarded-Proto $scheme;\n        proxy_set_header    Destination $fixed_destination;\n        # Fix the \xe2\x80\x9cIt appears that your reverse proxy set up is broken" error.\n        # might need to explicity set https://localip:port\n        proxy_pass          $fixed_destination;\n        # force timeout if backend died.\n        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;\n        proxy_read_timeout  90;\n        proxy_redirect http:// https://;\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

  • 看起来这是不可能的。Nginx 不做转发代理。[https 和 nginx 作为转发代理](https://forum.nginx.org/read.php?2,15124,15256#msg-15256)。 (3认同)