nginx proxy_pass 到 https

joe*_*g07 4 nginx proxy reverse-proxy

因此,我想将 proxy_pass 请求发送到 https 后端服务器,但是,每次尝试使用 https:// 配置的后端重新加载 nginx 服务器时,都会出现以下错误:

nginx: [emerg] https protocol requires SSL support
Run Code Online (Sandbox Code Playgroud)

这是nginx配置

server{

    listen 8080;

    root /opt/nginx_1.17.0/nginx_ok/html;
    server_name www.frontedndomain.com;

    index index.php index.html;

            location /health-monitor/ {
                    add_header Custom-Header test;
            }

            location ~* ^\/([a-z][a-z]\/)?abc\/?(.*)? {
                    error_log /opt/nginx_1.17.0/nginx_ok/logs/proxy_error.log;
                    add_header X-query-string $is_args$query_string;
                    resolver 0.0.0.0;
                    resolver_timeout 15s;
                    proxy_pass https://backenddomain.com;
                    proxy_ssl on;
                    proxy_http_version 1.1;
                    proxy_set_header Accept-Encoding "";
                    proxy_set_header Cache-Control no-cache;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection 'upgrade';
                    proxy_set_header X-Real-IP $remote_addr;
                    subs_filter_types *;
           }
    }
Run Code Online (Sandbox Code Playgroud)

最初我已经为源构建了 nginx,这是 nginx -V 的输出

nginx 版本:由 gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 构建的 nginx/1.16.0 配置参数:--prefix=/opt/nginx_1.17.0/nginx_ok/ --sbin-path=/ opt/nginx_1.17.0/nginx_ok/sbin/nginx --with-openssl=/opt/nginx_1.17.0/openssl-1.1.1c/ --add-module=/opt/nginx_1.17.0/ngx_http_substitutions_filter_module/ --with-zlib =/opt/nginx_1.17.0/zlib-1.2.11/

有人可以请概述我从这个配置中遗漏了什么。我还想将查询字符串转发到后端。

joe*_*g07 8

该问题已通过添加以下指令解决

proxy_ssl_server_name 开启;

这允许请求由上游端点的证书 SNI 中指定的服务器处理。

  • 我可以确认这有效。 (2认同)