根据每次请求的url地址,hash后访问到固定的服务器节点。
upstream tomcats {
# url hash
hash $request_uri;
# 最少连接数
# least_conn
server 192.168.1.173:8080;
server 192.168.1.174:8080;
server 192.168.1.175:8080;
}
server {
listen 80;
server_name www.tomcats.com;
location / {
proxy_pass http://tomcats;
}
}