问题原文
原帖链接 · A X · CC BY-SA 4.0
I have an NGINX TCP load balancer with the following configuration:
user myusername;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
load_module /usr/lib/nginx/modules/ngx_stream_module.so;
events {
worker_connections 1024;
}
stream {
upstream api_backend_http {
server myserver1.mydomain.com:80;
server myserver2.mydomain.com:80;
}
upstream api_backend_https {
server myserver1.mydomain.com:443;
server myserver2.mydomain.com:443;
}
server {
listen 80;
proxy_pass api_backend_http;
proxy_buffer_size 16k;
proxy_connect_timeout 1s;
}
server {
listen 443;
proxy_pass api_backend_https;
proxy_buffer_size 16k;
proxy_connect_timeout 1s;
}
}
The DNS TTL of myserver1.mydomain.com is set to 30 seconds. 45 Minutes after changing this, NGINX is still sending traffic to the old IP address.
This shouldn't happen - ideally it should respect the TTL of the upstream server DNS name. But it doesn't seem to be doing that. Does anyone know what the actual TTL is, and how to change it?
Side note, this feels like a bug in NGINX.
已采纳解答
原帖链接 · A X · CC BY-SA 4.0
After spending time on this, it seems that you basically have to buy NGINX Plus if you want this and also want to have multiple upstreams.
So consider looking at Envoy. It is free with a great license, and has both DNS refresh and upstream healthchecks built in.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
