NGINX配置,以通过HTTPS和NGINX作为客户端将流量发送到服务器

问题描述 投票:0回答:1

我有一个后端docker容器,它将连接到外部服务器,在这两个容器之间有一个NGINX服务器。从Docker容器到NGINX的连接是通过HTTP,从NGINX到服务器的连接是通过HTTPS。

我们已通过服务器认证的client.crt和client.key文件进行连接。当我们直接在下面使用它时,它将起作用。

# curl -i -X POST -d @event.json --header "Content-Type: application/json" https://localhost:8443/eventListener/v7 -k --cert client.crt --key client.key
HTTP/1.1 100

HTTP/1.1 202
Content-Type: application/json
Content-Length: 8
Date: Sat, 16 May 2020 15:41:12 GMT

Accepted
#

现在,我希望NGINX后面的docker容器可以连接到服务器。

nginx proxy ssl-certificate reverse-proxy nginx-reverse-proxy
1个回答
0
投票

下面是配置。

worker_processes 1;
events { worker_connections 1024; }
http {
     sendfile on;

     server {
          listen 1111;
          server_name 10.211.2.231;

          location / {
               proxy_pass https://10.211.2.231:8223$request_uri;
               proxy_ssl_certificate /etc/nginx/ssl/client.crt;
               proxy_ssl_certificate_key /etc/nginx/ssl/client.key;
               proxy_ssl_session_reuse on;
          }
     }
}
© www.soinside.com 2019 - 2024. All rights reserved.