nginx反向代理tomcat
1.配置tomcat-1
修改server.xml里三个端口号
server port 8005-8015
connector http port 8080-8888
connector ajp port 8009-8019
2.配置tomcat-2
修改server.xml里三个端口号
server port 8005-8025
connector http port 8080-9999
connector ajp port 8009-8029
3.修改一下tomcat里的欢迎页,方便看负载分担
4.配置nginx
在nginx.conf里增加
upstream serverpool {
server localhost:8888;
server localhost:9999;
}
server {
listen 99;
server_name localhost;
location / {
proxy_pass http://serverpool/;
}
}
然后打开浏览器访问localhsot:99,多次刷新发现它不断切到不同tomcat