AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 978922
Accepted
joebegborg07
joebegborg07
Asked: 2019-08-13 06:02:32 +0800 CST2019-08-13 06:02:32 +0800 CST 2019-08-13 06:02:32 +0800 CST

nginx proxy_pass 到 https

  • 772

所以我想将请求代理传递到 https 后端服务器,但是,每次我尝试使用 https:// 配置的后端重新加载 nginx 服务器时,都会收到以下错误:

nginx: [emerg] https protocol requires SSL support

这是 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 *;
           }
    }

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

nginx 版本: nginx/1.16.0 由 gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 构建 配置参数: --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/

有人可以请概述我在此配置中缺少的内容。我还想将查询字符串转发到后端。

nginx
  • 3 3 个回答
  • 23433 Views

3 个回答

  • Voted
  1. Best Answer
    joebegborg07
    2019-08-15T01:10:40+08:002019-08-15T01:10:40+08:00

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

    proxy_ssl_server_name 开启;

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

    • 8
  2. Aslan Varoqua
    2019-08-13T14:39:55+08:002019-08-13T14:39:55+08:00

    您正在侦听没有 SSL (http) 的端口 8080,并尝试代理到端口 443 (https) 上启用 SSL 的主机。如果这行得通,它基本上会使加密变得毫无意义,因为它只会在您的一端加密,而不是在数据包传输到您的客户端时加密。解决方案是确保您为相关端口安装了证书并启用了 ssl,并且任何 proxy_pass 都不会从未启用 ssl 的端口转发到启用 ssl 的端口。

    • 1
  3. Matheus Santz
    2021-06-14T02:23:36+08:002021-06-14T02:23:36+08:00

    我遇到了同样的问题,因为我的DNS 主机提供商有https,我不需要加密我的连接2 次,因为它会更慢。

    它对我有用,如下所示:

      upstream backend {
            server node_socket1:3000 weight=10 max_fails=3 fail_timeout=30s;
            server node_socket2:3000 weight=10 max_fails=3 fail_timeout=30s;
      }
    
      server {
            listen 80;
            server_name 0.0.0.0;
            root  /var/www/public;
    
            location / {
                  try_files $uri $uri/ https://backend;
            }
    
            location /socket.io/ {
                  proxy_http_version    1.1;
                  proxy_redirect        off;
                  proxy_set_header      Upgrade $http_upgrade;
                  proxy_set_header      Connection "upgrade";
                  proxy_set_header      Host $host;
                  proxy_set_header      X-Real-IP        $remote_addr;
                  proxy_set_header      X-Forwarded-For  $proxy_add_x_forwarded_for;
                  proxy_set_header      X-NginX-Proxy    true;
                  proxy_pass            https://backend/socket.io/;
            }
      }
    
    • 1

相关问题

  • Gzip 与反向代理缓存

  • nginx 作为代理的行为

  • Nginx 学习资源 [关闭]

  • 提供 70,000 个静态文件 (jpg) 的最佳方式?

  • 在 Apache、LightTPD 和 Nginx Web 服务器上提供 PHP 5.x 应用程序的现状?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve