准备三个 tomcat:tomcat1、tomcat2、tomcat3,ROOT全部换成一个静态页面,方便查看演示
准备 nginx,配置 nginx.conf,weight 值越大,访问的次数就越多
upstream tomcats {
server 127.0.0.1:8081 weight=5;
server 127.0.0.1:8082 weight=1;
server 127.0.0.1:8083 weight=1;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://tomcats;
}
}
启动 nginx,访问 192.168.1.201,tomcat1、2、3 都会出现,但是 tomcat1 出现的次数较多,因为权重较大