码迷,mamicode.com
首页 > 其他好文 > 详细

nginx 单个端口布置多个单页应用

时间:2018-10-19 16:08:13      阅读:325      评论:0      收藏:0      [点我收藏+]

标签:打包   文件夹   localhost   api   地址   sha   har   一个   http   

目标:

       1、在80端口布署2个单页应用

       2、单页应用采用h5 history路由。

       3、地址栏 以 ‘http://ip/1/‘ 开头, 则 去第一个单页应用,以‘http://ip/2/’开头 去第二个单页应用。

 

需要修改:

     1、前端代码: 第一个单页应用应以 1作为基础路由,第二个单页应用应以2作为基础路由。例: 第一个应用中去 /home主页,则地址栏是 /1/home 。

     2、打包文件publicPath改为 ‘1‘,使引用路径都加上/1/。例:

<script src=/1/js/chunk-vendors.2a8e7123.js> </script> <script src=/1/js/app.dd1c6375.js> </script> </body> </html>

     3、nginx配置如下:

 server {
        listen       8000;
        server_name  localhost;
        root D:/nginx/nginx-1.13.12/html;
        location ^~/1/{
           try_files $uri  index1.html  /index1.html;
        }
        location ^~/2/{
            try_files $uri  index2.html  /index2.html;
        }

        location ^~/api/{
            proxy_pass http://10.15.4.113:9000/;
        }
}

html文件夹里面结构:

│  index1.html
│  index2.html
│  tree.txt
│  
├─1
│  ├─xxx
│       
└─2
  |─xxx // 这儿是app2的文件 

  

 

nginx 单个端口布置多个单页应用

标签:打包   文件夹   localhost   api   地址   sha   har   一个   http   

原文地址:https://www.cnblogs.com/gsgs/p/9816444.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!