5月30日19:06:00
nginx vue项目配置
server {listen 9888;server_name 127.0.0.1;error_log /data/log/nginx/houtai-error.log;access_log /data/log/nginx/houtai-access.log;root "/data/wwwroot/houtai";index index.html;charset utf-8;location / {autoindex off;try_files $uri $uri/ /index.html;}
nginx反向代理配置
这个主域名的二级目录反向代理过去
location /houtai/ {proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header Remote_addr $remote_addr;proxy_pass http://127.0.0.1:9888/;}
但是会造成js css 静态文件无法访问
vue 2.6.x
vue.config.js
publicPath: process.env.NODE_ENV === 'production' ? '/houtai' : '/',
就可以了
可以在dist文件夹,index.html文件 引用文件是否有houtai 前缀