准备环境:
192.168.40.246Centos7.2 Nginx tomcat
192.168.40.247Centos7.2 Nginx tomcat
#load balancing
upstream huwj.com {
ip_hash;
server192.168.40.246:8009;
server192.168.40.247:8009;
}
server{
listen 80;
#port_in_redirectoff;
server_name huwj.com;
location / {
proxy_pass http://huwj.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Ip_hash是指根据访问的IP源分配到固定的负载服务器,解决session共享问题
8009端口是web监听端口
server配置对应的域名即可
huwj.com 对应访问的域名,可解析至 两台服务器IP
原文链接:/centos/376683.html