tomcat安装
安装nginx
配置nginx
nginx的默认安装目录/etc/nginx
配置文件时nginx.conf
新配置式(假设需要部署的站点是qqq.baidu.com) ) ) ) ) ) ) ) )。
vim/etc/nginx/conf.d/qqq.Baidu.com.conf
服务器{
#监听端口
listen 80
#站点名称
server_name qqq.baidu.com;
#站点根目录
根/万维网/
位置/{
#默认主页配置
index index.html;
}
}
vim/etc/nginx/conf.d/proxy _ qqq.Baidu.com.conf
服务器{
#监听端口
listen 80
#站点名称
server_name qqq.baidu.com;
位置/{
#可访问的站点ip :端口或域名: ip
proxy _ pass http://192.168.72.15633608080;
}
}
启动nginx
systemctlstartfirewalld.service
启动时报告错误查看错误日志后,根据错误内容自己百度
systemctl status nginx.service
启动后访问目标站点时,显示错误403。 请参照以下内容
负载平衡配置
后缀conf就可以了。 效果和写在nginx.conf的http上的一样
创建编辑文件qqq.baidu.com.conf
vim/etc/nginx/conf.d/qqq.Baidu.com.confupstreamtomcatserver1{ server 192.168.72.1563:8080; 服务器192.168.72.156:8081; }server { listen 80; server_name qqq.baidu.com; location/{proxy_pass3358Tomcat服务器1; 索引索引. html index.htm; }重新启动服务后,将获得负载平衡的效果