前端部署
打开/usr/local/nginx/conf/nginx.conf
修改代理路径
启动nginx
发现端口被占用,先关闭nginx
在启动
[root@localhost sbin]# /usr/local/nginx/sbin/nginx -s stop
[root@localhost sbin]# ./nginx
后端jar包部署
进入ruoyi目录并运行jar包
[root@localhost ruoyi]# nohup java -jar ruoyi.jar &
前后的关联,打开/usr/local/nginx/conf/nginx.conf
在nginx.conf中添加如下代码
location /prod-api/{
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://192.168.0.104:8080/;
}
重启nginx
[root@localhost ruoyi]# /usr/local/nginx/sbin/nginx -s reload
集群部署
一个前端部署,多个后端部署
编辑/usr/local/nginx/conf/nginx.conf
upstream ruoyi{
server 192.168.0.100:8080 weight=5
server 192.168.0.104:8080 weight=3
}
location /prod-api/{
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://ruoyi/;
}
通过看日志来看,那个后端在起作用
进入log目录后,使用命令监控日志
tail -f sys-info.log