上传vue项目至服务器
比如/path/vue-resource-path
nginx配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| server { #listen 80; listen 443 ssl; server_name yourdomain.com;
#证书和密钥位置 ssl_certificate /etc/cert/xxx.ca; ssl_certificate_key /etc/cert/xxx.key;
location / { root /path/vue-resource-path;
#设置html不缓存 if ($request_filename ~* .*\.(?:htm|html)$){ add_header Cache-Control no-store; }
try_files $uri $uri/ @router; index index.html index.htm; }
#重写路由, 防止刷新的时候报404或者500错误 location @router { rewrite ^.*$ /index.html last; }
#后端接口代理 location /api/ { proxy_pass http: proxy_set_header Host $proxy_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
|
注意: 这个nginx的用户与vue项目所在目录的归属要保持一致,否则会有权限问题导致网页打不开