对WebService的应用程序利用Nginx进行分布式部署,upstream 的分配方式是ip_hash,但是,不同的IP(10.5.110.92-254)请求只被分配到其中一个server上,请问是什么问题?谢谢。
nginx.conf配置:
- XML code
worker_processes 1;error_log logs/error.log info;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 8777; server_name localhost; access_log logs/host.access.log; location / { root html; index index index.htm; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://localhost; } } upstream localhost { ip_hash; server 127.0.0.1:18777; server 127.0.0.1:28777; }}
------解决方案--------------------------------------------------------
The key for the hash is the class-C network address of the client
我也遇到这个问题,感觉IP_HASH没作用