我正在尝试设置一个 nginx,它可以根据域名将加密的 tcp 流传递到另一个应用程序,或者充当提供自己证书的反向代理。
\n\n我想归档以下情况:
\n\n https://app1.app.com \xe2\x94\x80\xe2\x94\x80\xe2\x96\xba pass-through encrypted tcp to :10001\n https://app2.app.com \xe2\x94\x80\xe2\x94\x80\xe2\x96\xba pass-through encrypted tcp to :10002\n https://app3.app.com \xe2\x94\x80\xe2\x94\x80\xe2\x96\xba serve ssl, reverse-proxy to http://ip:10003\nRun Code Online (Sandbox Code Playgroud)\n\n因此,在不破坏应用程序 1 和 2 的加密连接的情况下,nginx 应该转发 tcp 数据包。证书将由申请本身提供。主机名检测与 ssl_preread 一起使用。
\n\n但应用程序 3 只能通过 http 访问,因此 nginx 应该提供证书本身并代理从特定主机名app3.app.com到未加密后端的所有内容。
我有一个适用于前两种情况的工作配置,并且可以设置第三种情况,但无法弄清楚如何将这两种情况组合到一个 nginx 配置中。
\n\n到目前为止我所拥有的:
\n\nuser www-data;\nworker_processes 1;\n\nload_module /usr/lib/nginx/modules/ngx_stream_module.so;\n\nhttp {\n include /etc/nginx/mime.types;\n default_type application/octet-stream;\n\n log_format main \'$remote_addr - $remote_user [$time_local] "$request" \'\n \'$status $body_bytes_sent "$http_referer" \'\n \'"$http_user_agent" "$http_x_forwarded_for"\';\n\n access_log …Run Code Online (Sandbox Code Playgroud)