问题原文
原帖链接 · dmi_ · CC BY-SA 3.0
I would like to temporarily route no traffic to a host in an nginx upstream. Rather than commenting it out, as this means nginx would be completely programmatically unaware of it, I was wondering whether setting its weight to zero would have the same effect (routing no traffic to the host). This is unclear from the documentation here http://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream
Will nginx honor weight=0?
已采纳解答
原帖链接 · ankon · CC BY-SA 3.0
From a (fairly cursory) reading of ngx_http_upstream_get_peer it seems nginx will pick a weight=0 server if there is nothing else to pick at all.
Specifically see https://github.com/nginx/nginx/blob/3fae83a91c6e5cda012adf6ee2783273e747f613/src/http/ngx_http_upstream_round_robin.c#L558
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
