Iam新的nginx和我有这个问题,我不明白。
Iam使用nginx作为负载均衡器到三台云服务器。这是nginx的configuration:
upstream dummyname { server #.#.#.# weight=1; server #.#.#.# weight=1; server #.#.#.# weight=1; } server { listen 80; root /var/www/html; try_files /maintenance.html $uri $uri/index.html $uri.html @proxy; server_name localhost; location @proxy { proxy_pass http://dummyname; } }
我的问题出现了,当我在上游销毁其中的一个ip时,我开始出现这个错误:
ERROR The requested URL could not be retrieved The following error was encountered while trying to retrieve the URL: http://dummyname Unable to determine IP address from host name "dummyname" The DNS server returned: Name Error: The domain name does not exist. This means that the cache was not able to resolve the hostname presented in the URL. Check if the address is correct. Your cache administrator is webmaster.
跟踪这个错误后,我发现问题是在删除的服务器的IP地址,如果我从我的上游移除IP,它工作正常。
现在是不是nginx应该平衡负载,忽视任何非工作ips或是正常或Iam做错了什么? 任何参考非常赞赏。
提前致谢。
您应该在上游块中提高fail_timeout值,这样失败的服务器将被标记为失败。
(引用nginx文档,大胆是我的)从http://nginx.org/en/docs/http/ngx_http_upstream_module.html
fail_timeout = time设置指定次数的不成功尝试与服务器进行通信的时间,以此来考虑服务器不可用; 以及服务器将被视为不可用的时间段。 默认情况下,该参数设置为10秒。