大网数据广告活动
服务器运维问答

Will nginx route no traffic to an upstream host with weight 0?

· 52CE 我爱测

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 zer…

问题原文

原帖链接 · 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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-07-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。