Run multiple Sites in single url on same port with NGINX

Posted By : S. Ajit | 18-Dec-2016

Run multiple sites in single url with NGINX

Consider that in your project you have multiple module such as admin panel , buyer front end , seller front end and you need to run these module in single url like localhost:8080/admin for admin ,localhost:8080/ for buyer and localhost:8080/seller for seller.The NGINX configuration that can be used is as follows:

 

server {
    listen 8080;
    server_name localhost;  
    root /home/ajit/git/univisior;

location / {
    alias /home/ajit/git/project-x/buyer/dist/;
    index index.html;
    try_files $uri $uri/ /index.html;

}
location /admin{
    alias /home/ajit/git/project-x/admin/dist/;
    index index.html;
    try_files $uri $uri/ index.html;

}

location /seller {
    alias /home/ajit/git/project-x/seller/dist/;
    index index.html;
    try_files $uri $uri/ /index.html;

}

location /api {
    proxy_pass http://localhost:3000/api;

 }

}

THANKS

About Author

Author Image
S. Ajit

Ajit is a software developer who loves solving problems and programming in C, C++, Java. He also has a passion to learn new technologies.

Request for Proposal

Name is required

Comment is required

Sending message..