【问题标题】:NGINX Configuration to send traffic to Server over HTTPS and NGINX being clientNGINX 配置通过 HTTPS 将流量发送到服务器,NGINX 是客户端
【发布时间】:2020-09-02 11:16:08
【问题描述】:

我有一个后端 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】:

    下面是配置。

    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;
              }
         }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-11-09
      • 2017-07-04
      • 1970-01-01
      • 2016-03-10
      • 1970-01-01
      • 2018-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多