正式環境中Nginx配置 VUE打包后dist目錄配置跨域, 同時設置靜態資源緩存
server { listen 80; server_name XXX.top www.XXX.top; sendfile on; #charset koi8-r; access_log /var/log/nginx/log/sycity.log main; root /sycity/RuoYi-Vue/ruoyi-ui/dist; location / { #root /sycity/RuoYi-Vue/ruoyi-ui/dist; index index.html; try_files $uri $uri/ /index.html; #Vue路由history模式添加該行, 若不是則移除該行 } #以下配置是請求代理跨域 http://xxx.top/prod-api/XXX 反向代理請求http://127.0.0.1:8080/XXX location ^~ /prod-api { rewrite ^.+prod-api/?(.*)$ /$1 break; include uwsgi_params; proxy_pass http://127.0.0.1:8080; } #靜態資源 location ~ .*\.(js|css|jpg|png|gif)$ { expires 2d; }
}
