Nginx single Port layout multiple single page applications

Source: Internet
Author: User

Goal:

1, 80 Port Deployment 2 single page application

2. Single page application adopts H5 history route.

3, the Address bar starts with ' http://ip/1/', then goes to the first single page application, starts with ' http://ip/2/' to go to the second one page application.

Need to be modified:

1, front-end code: The first single-page application should be 1 as the base route, the second single-page application should be 2 as the base route. Example: The first app goes to/home, the Address bar is/1/home.

2, packaging files Publicpath to ' 1 ', so that the reference path is added/1/. Cases:

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

3, Nginx configuration is as follows:

server {        Listen       8000;        server_name  localhost;        Root D:/nginx/nginx-1.13. /html;         ^~/1/{           try_files $uri  index1.html  /index1.html;        }         ^~/2/{            try_files $uri  index2.html  /index2.html;        }         ^~/api/{            proxy_pass http://10.15.4.113:9000/;         }}

HTML folder inside Structure:

│  index1.html│  index2.html│  tree.txt│  ├─1│  ├─xxx│       └─2  

  

Nginx single Port layout multiple single page applications

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.