多个前端项目部署在同一个域名下
- 在vue.config.js中设置 publicPath: ‘/web/’
-
在路由index.js中设置 base:‘/web/’
-
在index.html中加入
-
修改NGINX设置,基本就是使location /指向原来的web前端, location /web指向新的web前端
server { listen 1024; listen [::]:1024; server_name localhost; access_log /var/log/nginx/host.access.log main; error_log /var/log/nginx/error.log error; location /web { alias /usr/share/nginx/dist/; try_files $uri $uri/ /web/index.html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location /jeecg-boot/ { 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://172.19.0.1:9999/; } }