收藏文章 楼主

带二级目录的 nginx 配置------目前找到的最简单的方法

版块:网站建设   类型:普通   作者:小绿叶技术博客   查看:805   回复:0   获赞:0   时间:2021-09-14 19:09:08

#---- 修改 vue.config.js -----#

 

添加配置 baseUrl: '/dist/',

 

 

#---- 修改 router/index.js ----#

 

const router = new VueRouter({

  mode: 'history',

  base: '/dist/',

  routes

})

 


 

#--- step3: 配置nginx ---#

 

在本地目录下,创建conf.d文件夹,里面随意创建任意文件,扩展名为.conf


我在本地目录下新建了一个conf.d文件夹,里面创建了一个test.conf文件


文件中添加如下配置(以vue项目为例):

复制代码

  server {

        listen       80;

        server_name  localhost(域名);

        root E:/vue/prog/nginx-root/dist;  -------nginx指向目录

        autoindex on;    -------------自动锁死在index.html里

        index  index.html index.htm;

        charset utf-8; 

        location /api {

            proxy_pass http://反向代理的地址;

        }

        location / {

            try_files $uri $uri/ /index.html;  -----vue官网上的配置,假设路径路由找不到的时候,默认跳转到首页index上

        }

     

    }

复制代码

提供企业建站服务,免费网防系统,提交信息登录 http://yundun.ddoss.cn 邮箱: proposal@ddoss.cn 
回复列表
默认   热门   正序   倒序

回复:带二级目录的 nginx 配置------目前找到的最简单的方法

头像

用户名:

粉丝数:

签名:

资料 关注 好友 消息