Nginx对WebService分布式部署,ip_hash失效
对WebService的应用程序利用Nginx进行分布式部署,upstream 的分配方式是ip_hash,但是,不同的IP(10.5.110.92-254)请求只被分配到其中一个server上,请问是什么问题?谢谢。
nginx.conf配置:
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.html 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;
}
}