反向代理HTTPS请求作为到上游服务器的HTTP

时间:2020-05-27 13:00:47

标签: nginx

我们正在cPanel服务器上使用NGINX来反向代理ZKTeco ZKBioSecurity服务器。由于与某些不支持HTTPS的设备兼容,我们所有的服务器都使用HTTP,但是,当然,到我们的NGINX服务器的所有会话均由HTTPS和cPanel的AutoSSL提供的Sectigo证书保护。

这是问题所在:看来ZKBioSecurity服务器正在检测到客户端正在使用HTTPS通过NGINX连接到它们,因此,每次您要登录时,都给出以下提示,建议您下载并安装ISSOnline驱动程序和证书。但是,证书是针对127.0.0.1颁发给ZKBioSecurity服务器的,因此,当我们使用FQDN连接到NGINX服务器时,这当然毫无意义。如果我们使用HTTP,则不会发生这种情况:

Driver Detection Exception Prompt

所以我的问题:NGINX转发给上游服务器的请求(也许是HTTP标头?)中是否包含客户端用来连接服务器的协议(HTTPS)?因为似乎是这样。

这是我们针对ZKBioSecurity服务器的NGINX配置:

location /.well-known {

    root /home/novacloud/public_html/subdomain/.well-known;
    allow all;
    try_files $uri = 404;

}

location / {

    if ($scheme = http) {
        return 301 https://$host$request_uri;
    }

    proxy_pass http://192.168.0.1:8080;
    proxy_http_version  1.1;
    proxy_cache_bypass  $http_upgrade;

    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-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host  $host;
    proxy_set_header X-Forwarded-Port  $server_port;

}

server_name指令当然由cPanel管理。上面是我们在主要cPanel NGINX配置文件中使用的包含文件的示例。我以为是proxy_set_header X-Forwarded-Proto $scheme,但是即使删除了它,我仍然会收到Driver Detection Exception提示。

Here’s a Pastebin of a cURL of the ZKBioSecurity server from our cPanel/NGINX server

0 个答案:

没有答案