宝塔面板云服务器部署Vue项目注意事项


linux静默启动及查看命令

静默运行指令: nohup java -jar ruoyi-admin.jar &

查看静默运行的日志:tail -f nohup.out

1、代理在生产版本失效。
Nginx代理设置:

location /prod-api{
  rewrite ^.+prod-api/?(.*)$ /$1 break; //可选参数,正则验证地址
  //可选参数,uwsgi是服务器和服务端应用程序的通信协议,规定了怎么把请求转发给应用程序和返回
  include uwsgi_params; 
  proxy_pass http://8.130.14.192:7777; // 接口地址
}

2、端口跨域
Ngnix跨域请求放行配置:

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

3、部署网页刷新404
vue页面打包上传服务器刷新出现404 Not Found nginx

原因:url地址是虚拟的,不是真实存在的,包括页面也是js控制,所以刷新就找不到文件而报404;需要配置Nginx解决。


location / {
   try_files $uri $uri/ @router;
   index index.html;
}
 
location @router {
    rewrite ^.*$ /index.html last;
}

posted @ 2022-06-28 14:55  吕业浩  阅读(859)  评论(0)    收藏  举报