blog icon indicating copy to clipboard operation
blog copied to clipboard

nginx配置多个vue项目

Open chenyinkai opened this issue 6 years ago • 3 comments

nginx配置多个vue项目

需求

nginx 下配置多个 vue 项目,或者说非根目录下的配置

举例:

  • blog: https://www.yoursite.com/blog
  • test: https://www.yoursite.com/test

vue项目中配置

vue-router 设置 base 路径

base: '/blog'

config/index.js 修改 assetsPublicPath

assetsPublicPath: '/blog/'

nginx配置

location /blog {
  try_files $uri $uri/ /blog/index.html;
}

chenyinkai avatar Apr 18 '18 04:04 chenyinkai

location /blog { try_files $uri $uri/ /blog/index.html; } location /test { try_files $uri $uri/ /test/index.html; } 不是这样配置么???

hu949277923 avatar Jan 08 '19 09:01 hu949277923

@hu949277923 额,有区别吗? testblog 一样就没写了

chenyinkai avatar Jan 09 '19 01:01 chenyinkai

有没有试过不需要每个新项目都去添加nginx配置的方式

feng138168 avatar Mar 04 '20 10:03 feng138168