下载若依项目,前端后端项目本地启动 前端打包,后端打包 配置nginx.conf 需要注意的是:路径别用中文,要不然报错
#前台访问地址及端口80,在vue.config.js中可查看server {listen 80;server_name localhost;
#后台访问地址http://localhost:8080/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就是设置的代理后的地址,即自己服务器后台接口的urlproxy_pass http://localhost:8080/;}# root:dist静态页面根目录地址 index:dist中html文件的名字location / {root C:/Users/18427/Desktop/windowsBUSHUTest/dist;try_files $uri $uri/ /index.html;index index.html index.htm;}# windows中无需配置第一行的user
启动nginx,访问localhost:80 参考:
https://blog.csdn.net/qq_40183977/article/details/130001512 https://blog.csdn.net/qq_39533140/article/details/113487899