Nginx上游超时或仅在上游代理上提前关闭上游
我发现nginx的负载平衡器有问题。我使用nginx作为反向代理 这里是我的nginx配置->Nginx上游超时或仅在上游代理上提前关闭上游,nginx,proxy,load-balancing,Nginx,Proxy,Load Balancing,我发现nginx的负载平衡器有问题。我使用nginx作为反向代理 这里是我的nginx配置-> user nobody; worker_processes 8; worker_rlimit_nofile 400000; error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events {
user nobody;
worker_processes 8;
worker_rlimit_nofile 400000;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 4042;
use epoll;
multi_accept on;
}
http {
upstream lb {
ip_hash;
server ip1;
server ip2;
server ip3;
}
server {
listen 80 default backlog=10000;
server_name myservername.com;
client_header_timeout 15s;
client_body_timeout 15s;
##########################################
#### Proxy without cache ####
#### ####
location / {
proxy_pass http://ip1;
#proxy_pass http://lb;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
...
ip1/ip2/ip3是带有php cgi的Web服务器lighttpd
当nginx的配置设置在代理服务器上时,直接通过ip1或ip2或ip3,所有工作正常无误,连接快速
现在,如果我使用代理传递http://lb,我得到了很多错误后,只有2分钟的运行,即使在低流量的时间和连接到该网站是非常缓慢,或这个网页是没有正确重定向
connect() failed (111: Connection refused) while connecting to upstream
upstream prematurely closed connection while reading response header from upstream
upstream timed out (110: Connection timed out) while reading response header from upstream
我的问题是,为什么使用上游/负载平衡,nginx无法工作?后端服务器的行为有什么不同吗?当这些服务器出现故障时,它们的错误日志中有什么?看起来确实有些后端服务器出现了错误,可能是反向代理nginx的问题。我加上值max_fails=3 fail_timeout=15s;在上游的IP上,目前为止,一切都很好,但我仍在监控问题是否会再次发生。