Blog

  • 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

Tags: nginx