vue-router+nginx非根路径的配置方法


一、直接配置在根路径下

直接配置在根路径下,访问的时候只用输入http://1.15.179.248:8089(这边没有域名用ip代替),在nginx的配置如下

 

 二、非根路径配置

如果一个域名下有多个项目,那么使用根路径配置就不合适了,我们需要在根路径下指定一层路径,比如说

后台管理系统admin

http://1.15.179.248:8087/admin/

配置如下

 

 代码

 server {
        listen       8087;
        server_name  1.15.179.248;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location /admin {
            alias /data/admin-test/;  // 此处为admin项目放置的路径
            try_files $uri $uri/ /admin/index.html;
            index  index.html index.htm;
        }
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}

注意要用alias不能用root

参考文章:https://www.php.cn/js-tutorial-406275.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM