`我有 nginx pod 正在运行并向不同的后端发出代理请求。
部署后,它会在几个小时内运行良好,然后开始花费太多时间并使用 504 状态代码获取网关超时。
重要观察-
a) 此问题仅发生在与代理后端相关的请求之一。对于其他服务的代理请求继续正常工作。 b) 如果我直接尝试后端服务端点,它会在任何时间的几分之一秒内继续响应。
如果我再次重新部署 nginx pod,它又可以正常工作了。
根据 a) 点和 b) 点中的观察,很明显 - i) 它可能不是 nginx 资源的问题,因为其他代理后端请求工作正常 ii) 这也不是后端服务随着时间变慢的问题,因为我在任何时间点都会像往常一样得到响应。
这里可能是什么问题?
我尝试过以不同的方式更新 nginx 配置。但它似乎不起作用。
下面是 nginx.conf 的片段
worker_processes auto;
worker_rlimit_nofile 1024;
events {
accept_mutex on;
accept_mutex_delay 500ms;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log error;
sendfile on;
server_tokens on;
types_hash_max_size 1024;
types_hash_bucket_size 512;
server_names_hash_bucket_size 256;
server_names_hash_max_size 512;
keepalive_timeout 65s;
keepalive_requests 100;
client_body_timeout 60s;
send_timeout 60s;
lingering_timeout 5s;
tcp_nodelay on;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90s;
proxy_send_timeout 90s;
proxy_read_timeout 90s;
proxy_buffers 32 4k;
proxy_buffer_size 8k;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Proxy "";
proxy_headers_hash_bucket_size 64;
server {
listen 8080;
root /opt/app;
add_header "X-Frame-Options" "DENY";
location ~* \.(?:css|js)$ {
add_header Cache-Control "public, max-age=2592000";
try_files $uri =404;
}
location ~ ^.+\..+$ {
add_header Cache-Control "public, no-transform, max-age=84600";
try_files $uri =404;
}
location @index {
add_header Cache-Control "public, max-age=600";
try_files /index.html =404;
}
location / {
add_header Cache-Control "public, max-age=600";
try_files $uri @index;
}
location ^~ /a {
proxy_pass https://serviceahost:443;
}
location ^~ /b {
proxy_pass https://servicebhost:443;
}
}
}