title: Nginx reverse-proxy and root problem in multiple websites
body: <p>I have an IP address of my server that I want to put my website Frontend and Backend admin. The site1 part is simply should be at "<a href="http://IP/" rel="nofollow noreferrer">http://IP/</a>" and and site2 should be in "<a href="http://IP/admin" rel="nofollow noreferrer">http://IP/admin</a>" .</p>
  
  <p>I have installed Nginx in server and my websites files are inside: Lets say its like :</p>
  
  <pre><code>site1: /var/www/html/site1/index.html
  site2: /var/www/html/site2/index.html
  </code></pre>
  
  <p>I created 2 files in /etc/nginx/site-available/ called "site1.conf" and "site2.conf" .</p>
  
  <p>site1.conf:</p>
  
  <pre><code> server {
      listen 80;
      listen [::]:80;
  
   root /var/www/html/site1;                                       
   index index.html index.htm;                                
  
   server_name http://myIP;                         
  
   location / {                                               
  
       try_files $uri $uri/ =404;                         
   } 
  }                                                         
  </code></pre>
  
  <p>site2.conf: </p>
  
  <pre><code>server {
      listen 80;
      listen [::]:80;
   server_name http://myIP;       
  
   location /admin {                      
   autoindex on;                          
   alias /var/www/html/site2;             
   try_files $uri $uri/ /index.html last; 
   index index.html;                      
   }
  }  
  </code></pre>
  
  <p>Then I linked these 2 files into "/etc/nginx/site-enabled"</p>
  
  <p>After restarting the Nginx, my "<a href="http://ip/" rel="nofollow noreferrer">http://ip/</a>" opens site1 "index.html" and works fine.</p>
  
  <p>but "<a href="http://ip/admin/" rel="nofollow noreferrer">http://ip/admin/</a>" gives 404 error instead of opening site2 "index.html"</p>