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