接上一篇:RuoYi-Vue 部署 Linux环境 若依前后端分离项目(jar包+nginx 单机版本)
前端和后端不在一个服务器上,如何部署呢?
1. 服务器和软件部署
服务器ip | 说明 |
---|
192.168.92.102 | 后端 | 192.168.92.103 | 前端 |
服务器ip | 软件 |
---|
192.168.92.102 | redis | 192.168.92.102 | mysql | 192.168.92.103 | nginx |
2. 后端部署
java -jar ruoyi-admin.jar
./redis-server
3. 前端部署
将102服务器上的ruoyi-ui文件夹,上传到103的/app目录下
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /app/ruoyi-ui;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
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.92.102:8080/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
./nginx
4. 登录
http://192.168.92.103/
5. 效果图
|