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

Solution 1:

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

Solution 2:

I've tried to reload nginx with one upstream configured with weight=0 and it did not work.

Nginx said:

nginx: [emerg] invalid parameter "weight=0" in /etc/nginx/sites-enabled/upstream
nginx: configuration file /etc/nginx/nginx.conf test failed