tomcat动静分离负载均衡

需要三台nginx服务主机,2台tomcat主机

#nginx1

systemctl stop firewalld
setenforce 0
#关闭防火墙

vim /usr/local/nginx/conf/nginx.conf

#在http模块中添加
upstream tomcat {
server 192.168.233.66:8080 weight=1;
server 192.168.233.67:8080 weight=1;
}
#在location / { 
root html;
index index.html index.htm;
}
添加
location ~* \.jsp$ {
proxy_pass http://tomcat;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

nginx -t
#检测一下

vim /usr/local/nginx/html/index.html
100dd
输入需要的字符
wq保存退出
#将图片放入html目录下
systemctl restart nginx
#重启nginx

你可能感兴趣的:(tomcat,负载均衡,java)