我在容器(Kubernetes)中运行了 Nginx 和 App。使用 NginX 入口点进行 TLS 握手,配置如下
upstream app {
server app:8200;
}
server {
listen 443 ssl;
server_name localhost;
ssl_certificate /etc/ssl/util_example_com.crt;
ssl_certificate_key /etc/ssl/util_example_com.key;
ssl_client_certificate /etc/ssl/ca.crt;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_verify_client on;
location / {
proxy_pass http://app;
proxy_read_timeout 180;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
我可以curl http://app:8080/generator
从 Nginx 容器。但是,当我在公共端点上使用 curl ( https://util.example.com/generator
) 首先命中 Nginx 时,我504 Gateway Time-out
在 Nginx 中得到 & 跟随错误
2021/05/04 21:54:50 [error] 21#21: *1 upstream timed out (110: Connection timed out) while connecting to upstream, client: 10.2.16.183, server: localhost, request: "POST /generator HTTP/1.1", upstream: "http://172.20.154.113:8200/generator", host: "util.example.com"
任何帮助,这里发生了什么。
尝试删除所有非必要部分。例如,尝试以下最小工作示例:(编辑 sub.domain.tld)
从那里添加元素,直到找到导致超时的原因。