Nginx負載均衡的睏惑
測試環境是這樣的,A、B、C 3部server,
在server A部署Nginx,雙网卡192.168.1.188對外,192.168.0.2對內
B和C為鏡像站點,IP分別是192.168.0.11 192.168.0.12
本地綁定nginx.de到192.168.1.188以供外部訪問
B和C正常運行時,Nginx輪詢正常。但是停掉其中一個站點后,雖然Nginx會正確切換到存活的主機,但是切換的速度無比緩慢。
當然是配置有錯,不過問題在哪呢?
先存下conf如下,睏惑。。。
100108update:弄明白了,原來是由max_fails定義失敗次數,之後根據fail_timeout的設定禁用節點的時間。
user nginx nginx;
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
upstream nginx {
server 192.168.0.11:80 max_fails=3 fail_timeout=30s;
server 192.168.0.12:80 max_fails=3 fail_timeout=30s;
}
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 logs/access.log main;
client_body_timeout 10;
gzip on;
gzip_comp_level 6;
gzip_types text/* text/css application/javascript application/x-javascript;
server {
listen 80;
server_name nginx.de;
location / {
index index.html index.htm;
proxy_pass http://nginx;
}
location /NginxStatus {
stub_status on;
access_log on;
}
}
}