强制nginx验证上游证书

时间:2016-04-08 19:31:28

标签: ssl nginx

我正在尝试在代理路径的每一层建立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;
  }
}

2 个答案:

答案 0 :(得分:4)

使用

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

有关其他详细信息,请参阅nginx代理文档here

答案 1 :(得分:0)

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