使用自签名证书的 nginx http 到 https 代理

Jak*_*kob 21 proxy https certificate ssl

我有一个 nginx 代理,可以将具有指定端口的 http 请求重定向到另一个 https url。

到目前为止,这是我的配置:

server {
   listen 59848;
   location / {
      resolver 8.8.8.8;
      proxy_pass https://example.com$uri$is_args$args;
   }
}
Run Code Online (Sandbox Code Playgroud)

请注意,“example.com”仅用于此示例,稍后我将限制请求仅从本地主机发送。

这工作得很好,只要“proxy_pass”url 后面的服务器使用由知名 CA 机构签名的有效 SSL 证书(nginx 以某种方式使用该根证书)。

但是我有一个问题,我必须在 nginx 端使用自定义的自签名 SSL 客户端证书。有人知道如何将此自签名证书安装到 nginx 吗?

小智 18

nginx 默认允许使用自签名证书:

Syntax:     proxy_ssl_verify on | off;
Default:    proxy_ssl_verify off;
Context:    stream, server
Enables or disables verification of the proxied server certificate. 
Run Code Online (Sandbox Code Playgroud)

删除proxy_ssl_verify指令或将其设置为off.
在此处阅读更多相关信息:
https: //www.nginx.com/resources/admin-guide/nginx-tcp-ssl-upstreams/http :
//nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ssl_verify