【问题标题】:Force nginx to verify upstream certs强制 nginx 验证上游证书
【发布时间】:2016-04-08 19:31:27
【问题描述】:

我正在尝试在代理路径的每一层建立 TLS。我看到的是 Nginx 允许上游拥有自签名证书。将流量传递到上游时,是否有任何方法可以锁定接受的权限?

end-user  --1-->  nginx01  --2-->  nginx02  --N-->  nginxN

nginx01 具有受信任的证书,最终用户可以毫无问题地连接。 nginx02 有一个自签名证书,当我 proxy_pass 到 https://nginx02 时,我在最终用户浏览器或 nginx01 日志中看不到任何投诉。我希望被拒绝。 如果我按预期从 nginx01 卷曲 nginx02,我会收到 ssl 拒绝。

有没有办法强制 nginx01 验证 nginx02 证书?

CentOS 7 运行 nginx 1.6.3-8。

/etc/hosts
10.21.10.99 upstream.example.com

curl https://upstream.example.com
# ssl rejection

curl https://upstream.example.com --cacert ./upstream.example.com.crt
# works fine (200)

# nginx configuration
server {
  listen 443;
  ssl on;
  ssl_certificate /etc/nginx/security/full_chain.crt;
  ssl_certificate_key /etc/nginx/security/ingress.example.com.key;
  server_name ingress.example.com;
  location / {
    proxy_pass https://upstream.example.com;
  }
}

【问题讨论】:

    标签: ssl nginx


    【解决方案1】:

    使用

    proxy_ssl_verify on;
    proxy_ssl_trusted_certificate /path/to/your_selfsigned_ca_cert.pem
    

    更多细节可以参考nginx代理文档here

    【讨论】:

      【解决方案2】:

      我只需要升级以获得一些 proxy_ssl 指令。 http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ssl_verify

      【讨论】:

        猜你喜欢
        • 2017-08-19
        • 2021-12-05
        • 2015-06-14
        • 1970-01-01
        • 2021-10-20
        • 1970-01-01
        • 2020-09-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多