我们目前正在通过使用 Nginx 作为 UDP 负载平衡器来为我们的 UDP 工具 Logstash 实施高可用性解决方案。但是,我面临一个问题,在我们的配置文件中,我们试图将系统日志流量路由到后端 Logstash 服务器。但是,当其中一个 Logstash 服务器发生故障时,Nginx 会继续将日志转发到不可用的服务器,而不是将所有流量路由到可用的服务器。我们已将其配置为使用循环负载平衡,但它似乎没有按预期工作。
user nse;
worker_processes auto;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /home/nse/etc/nginx/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
error_log /home/nse/var/log/nginx/error.log info;
access_log /home/nse/var/log/nginx/access.log;
#access_log logs/access.log main;
#proxy_timeout 1s;
#proxy_responses 10;
#proxy_connect_timeout 180s;
#proxy_send_timeout 180s;
#proxy_read_timeout 180s;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
}
stream {
upstream logstash {
zone dns_zone 64k;
server 10.139.168.12:10514 fail_timeout=30s;
server 10.139.168.11:10544 fail_timeout=30s;
}
server {
listen 5144 udp;
proxy_pass logstash;
health_check interval=5 passes=2 fails=2 udp;
#proxy_timeout 1s;
#proxy_responses 1;
proxy_buffer_size 16k;
proxy_responses 60;
}
}