【web框架】【 Cloud-Admin学习笔记(二)】【前后端分离的发布配置】

因为spirng前后端分离设计,发布流程略有不同,前后端单独发布,通过nginx集成

1、前端项目打包

#转到前端项目根目录

cd D:\001\myProject\GitHub\AG-Admin-v2-UI

# 构建生成环境

cnpm run build:prod

然后等待服务器build,如果成功后会提示

打包成功后的文件在dist目录,把文件拷贝到nginx根目录下html\dist

2、nginx配置

         location / {
           # 指向我们打包后上传的前端文件
            root   html/dist;
            index  index.html index.htm;
        }
         location /jwt/ {
        # 转发请求到后端服务网关
        proxy_pass http://127.0.0.1:8765/jwt/;
        }
        location /api/ {
        proxy_pass http://127.0.0.1:8765/api/;
        }

3、重启nginx

猜你喜欢

转载自blog.csdn.net/qq_43659174/article/details/84714539
今日推荐