nginx - 如何强制 Nginx 针对上游服务器 block 中存在的主机名验证上游证书?

标签 nginx proxy ssl-certificate reverse-proxy

我正在尝试在代理路径的每一层实现 HTTPS 协议(protocol)通信。我的代理路径是从客户端到负载均衡器(nginx),然后从 nginx 到上游服务器。

当请求从 nginx 代理到上游服务器时,我遇到了问题。

我在 nginx 日志中收到以下错误

2017/03/26 19:08:39 [error] 76753#0: *140 upstream SSL certificate does not match "8ba0c0da44ee43ea894987ab01cf4fbc" while SSL handshaking to upstream, client: 10.191.200.230, server: abc.uscom-central-1.ssenv.opcdev2.oraclecorp.com, request: "GET /a/a.html HTTP/1.1", upstream: "https://10.240.81.28:8001/a/a.html", host: "abc.uscom-central-1.ssenv.opcdev2.oraclecorp.com:10003"

这是我对上游服务器 block 的配置
upstream 8ba0c0da44ee43ea894987ab01cf4fbc {
                            server slc01etc.us.oracle.com:8001 weight=1;
                    keepalive 100;
}

proxy_pass https://8ba0c0da44ee43ea894987ab01cf4fbc;
proxy_set_header Host $host:10003;
proxy_set_header WL-Proxy-SSL true;
proxy_set_header IS_SSL ssl;
proxy_ssl_trusted_certificate /u01/data/secure_artifacts/ssl/trusted_certs/trusted-cert.pem;
proxy_ssl_verify on;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

当请求从 Nginx 发送到上游服务器时,nginx 会将上游 ssl 证书与 proxy_pass 指令中存在的模式进行匹配。但我的上游 ssl 证书模式是上游服务器主机名 (slc01etc.us.oracle.com) 。

有什么办法可以强制 Nginx 针对上游服务器 block 中提供的服务器主机名验证上游 ssl 证书,而不是 proxy_pass 指令中存在的模式?

最佳答案

我们可以在 nginx 中使用“proxy_ssl_name”指令。它允许覆盖 nginx 验证后端服务器证书的主机名。

proxy_ssl_name mybackend-server.hostname.com;

关于nginx - 如何强制 Nginx 针对上游服务器 block 中存在的主机名验证上游证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43033509/

相关文章:

nginx - 命令在bash上运行,但不是从nginx conf exec运行

python - 从 Flask 返回 requests.Response 对象

python - 如何在 Azure Python SDK 中为 NetworkManagementClient 设置 session 代理?

c# - 动态代理集合接口(interface)

node.js - 如何配置axios使用SSL证书?

c# - TCP 客户端 C# : The remote certificate is invalid according to the validation procedure

ubuntu - 标准 nginx.conf 文件给出错误。在哪里包含服务器{}定义?

node.js - 将 pm2 的集群模块与 socket.io 和 socket.io-redis 一起使用

angular - Nginx for Angular没有达到后端api

ruby - gitlab-shell ssl 证书问题