title: Ngnix two server block one by domain another one by IP
body: <p>I am Trying to create two instance on my NGnix server </p>
  
  <p>First would be accessed by </p>
  
  <blockquote>
    <p>mydomain.com (it listening to port 80 )</p>
  </blockquote>
  
  <p>Second using</p>
  
  <blockquote>
    <p>172.32.32.123:81  (it listening to port 81 and this IP is server IP)</p>
  </blockquote>
  
  <p>this is my default file </p>
  
  <pre><code>server {
      listen 80 default_server;
      listen [::]:80 default_server;
  
  
      root /var/www/html;
  
      # Add index.php to the list if you are using PHP
      index index.php index.html index.htm index.nginx-debian.html;
  
      server_name mydomain.com;
  
      location / {
  
          try_files $uri $uri/ =404;
      }
  
          location ~ \.php$ {
          include snippets/fastcgi-php.conf;
          fastcgi_pass unix:/run/php/php7.1-fpm.sock;
      }
  
  
          location ~ /\.ht {
          deny all;
      }
  }
  server {
      listen       81;
      server_name  172.32.32.123:81;
      root /var/www/html/root;
     index index.html index.php;
     set $MAGE_MODE developer; # or production or developer
     set $MAGE_ROOT /var/www/html/root/;
  
     location / {
             try_files $uri $uri/ =404;
  
     }
           location ~ \.php$ {
              include snippets/fastcgi-php.conf;
      #
      #       # With php7.0-cgi alone:
      #       fastcgi_pass 127.0.0.1:9000;
      #       # With php7.0-fpm:
              fastcgi_pass unix:/run/php/php7.1-fpm.sock;
      }
  
      include /var/www/html/root/nginx.conf.sample;
  </code></pre>
  
  <p>}
      }</p>
  
  <p>The server block is working fine for the one when using domain name but in case of IP based domain only home page is working on inner pages we are getting 404 error</p>