Appearance
根据 cookie 做负载均衡,$cookie_jsessionid 表示根据 cookie 中的 jsessionid 字段 做负载均衡。
nginx
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream httpds {
# 开启 cookie 负载均衡
hash $cookie_jsessionid;
server 192.168.44.102;
server 192.168.44.103;
}
server {
listen 80;
server_name www.rainx.top;
location / {
proxy_pass http://httpds;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}