Score:0

How to serve 2 react apps on nginx with same ip and port

jp flag

I have two applications one is public and another one is admin, I want to serve these two apps on same port but it is not working, below is my configuration file:

build folder for both apps is saved in below directory

/var/www/html/admin/build

/var/www/html/public/build

Configuration file:

server{
    listen 80;
    server_name 192.xx.xx.42;
    
   location /public {
    root /var/www/html/public/build;
    index login.html;
   }
   
   location /admin {
      root /var/www/html/admin/build;
      index login.html
   }
}
Score:0
us flag

nginx adds the URI part of URL after the path specified in root directive.

This means that when requesting /public URI, nginx will look files in /var/www/html/public/build/public/ directory.

You can change the root to alias. In that case, the URI part is not appended to the path, only the filename.

Satish Lamak avatar
jp flag
I tried with alias as well, but it is giving 404 error for all the files even if the files are there in the directory...
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.