前者是nginx自监控,后者是nginx后端负载监控
nginx_stub_status的配置:
server{
location /nginx-status {
allow 192.168.4.51;
deny all;
stub_status on;
access_log off;
}
}
nginx_upstream_check_module的配置:
http {
upstream cluster {
# simple round-robin
server 192.168.0.1:8080 weight=1 max_fails=1 fail_timeout=3s;
server 192.168.0.2:8080 weight=1 max_fails=1 fail_timeout=3s;
check interval=10000 rise=3 fall=3 timeout=1000 type=http default_down=true port=80;
check_keepalive_requests 1;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;
}
server {
listen 80;
server_name localhost;
index index.html index.jsp index.htm;
gzip off;
access_log logs/8180_access.log main;
error_log logs/8180_error.log;
location / {
proxy_pass http://cluster;
#proxy_buffer_size 64k;
#proxy_buffers 32 32k;
#proxy_busy_buffers_size 128k;
proxy_redirect off;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_X_forwarded_for;
#proxy_buffering off;
#proxy_connect_timeout 60;
#proxy_send_timeout 60;
#proxy_read_timeout 60;
}
location /status {
check_status;
access_log off;
allow 192.168.4.51;
deny all;
}
}
}