前端部署

打开/usr/local/nginx/conf/nginx.conf修改代理路径
image.png
image.png
启动nginx
image.png
发现端口被占用,先关闭nginx在启动

  1. [root@localhost sbin]# /usr/local/nginx/sbin/nginx -s stop
  2. [root@localhost sbin]# ./nginx

浏览器打开ip地址访问前端
image.png

后端jar包部署

进入ruoyi目录并运行jar包

  1. [root@localhost ruoyi]# nohup java -jar ruoyi.jar &

image.png
前后的关联,打开/usr/local/nginx/conf/nginx.conf
image.png
在nginx.conf中添加如下代码

  1. location /prod-api/{
  2. proxy_set_header Host $http_host;
  3. proxy_set_header X-Real-IP $remote_addr;
  4. proxy_set_header REMOTE-HOST $remote_addr;
  5. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  6. proxy_pass http://192.168.0.104:8080/;
  7. }

image.png
重启nginx

  1. [root@localhost ruoyi]# /usr/local/nginx/sbin/nginx -s reload

集群部署

一个前端部署,多个后端部署
编辑/usr/local/nginx/conf/nginx.conf

  1. upstream ruoyi{
  2. server 192.168.0.100:8080 weight=5
  3. server 192.168.0.104:8080 weight=3
  4. }
  1. location /prod-api/{
  2. proxy_set_header Host $http_host;
  3. proxy_set_header X-Real-IP $remote_addr;
  4. proxy_set_header REMOTE-HOST $remote_addr;
  5. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  6. proxy_pass http://ruoyi/;
  7. }

image.png
通过看日志来看,那个后端在起作用
进入log目录后,使用命令监控日志

  1. tail -f sys-info.log