问题描述
在我的 Rancher 环境中,我使用内置的入口负载平衡器将流量路由到自定义 nginx,它的作用类似于 2 个“应用程序”的反向代理。在这种情况下,我选择要代理的服务器。一切正常,但随机时间后应用程序不可用。在浏览器中,我收到 504 和基本的 nginx 消息 An error occurred. blah blah Faithfully yours,nginx.
nginx
2021/02/25 19:46:27 [error] 31#31: *789 upstream timed out (110: Connection timed out) while connecting to upstream,client: X.X.X.X,server: _,request: "GET / HTTP/1.1",upstream: "http://10.42.0.36:8080/",host: "www.example.com"
2021/02/25 19:47:27 [info] 31#31: *789 client X.X.X.X closed keepalive connection
如果我重新启动 nginx 容器,几个小时后一切都会恢复。
配置
worker_processes auto;
error_log /dev/stdout info;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
multi_accept on;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout;
client_body_buffer_size 10K;
client_header_buffer_size 1k;
client_max_body_size 100m;
large_client_header_buffers 4 32k;
server_names_hash_bucket_size 64;
sendfile on;
tcp_nodelay on;
tcp_nopush on;
keepalive_requests 1000;
reset_timedout_connection on;
client_body_timeout 10;
send_timeout 5;
server_tokens off;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 8080 default_server;
server_name _;
charset utf-8;
underscores_in_headers on;
root /usr/share/nginx/html;
location / {
proxy_http_version 1.1;
proxy_read_timeout 120;
proxy_cache_bypass true;
proxy_no_cache true;
proxy_connect_timeout 20s;
if ($http_user_agent ~ someagent) {
proxy_pass http://app1:8000;
}
proxy_pass http://app2:8080;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)