Nginx在局域网内实现真正的ip_hash负载均衡
Nginx在局域网内实现真正的ip_hash负载均衡 遇到的问题 本人在以前公司的局域网内搭载Nginx负载均衡的时候发现使用 ip_hash 实现负载均衡会发生一个奇怪的显现,所有 客户端的请求 访问都打在了 同一个服务器 上! 这使得负载均衡根本就没有起到任何作用,本人查阅了相关资料最终发现解决方法,多谢网上的各位大神,参考文献在最后说明。 为什么无法实现在同一局域网内ip_hash负载均衡说明 在同一个局域网中,大多数情况下我们在同一局域网内的所有机器IP 前3位 都是相同的,假设都为192.168.1.xxx。 根据官方的解析(参考网上大神的说法) This directive causes requests to be distributed between upstreams based on the IP-address of the client. The key for the hash is the class-C network address or the entire IPv6-address of the client. IPv6 is supported for ip_hash since 1.3.2 or 1.2.2. This method guarantees that the client request will always be