title: NGINX access multiple sites same IP url
body: <p>I would like to know how I can have several sites on Nginx and be able to access each of them with the same IP (without the domain, since I am doing tests in a laboratory locally). </p>
  
  <p>I have the server on a separate PC and I access it remotely from my computer using the IP. Both are on the same LAN.</p>
  
  <p>In the directory /var/www/ I have two sites 'nextcloud' and 'phpmyadmin'. I would like to be able to enter both by placing (for example) 192.168.1.14/nextcloud and 192.168.1.14/phpmyadmin. Or having any other project in the www directory.</p>
  
  <p>I tried all the solutions I found, but none of them worked for me. When I enter phpmyadmin for example, it gives me to download the page instead of entering it.</p>
  
  <p>Within /etc/nginx/sites-enabled I have the two files, one from nextcloud:</p>
  
  <pre><code>
      server {
          listen 80 default_server;
          listen [::]:80 default_server;
  
          root /var/www/nextcloud/;
  
          index  index.php index.html index.htm;
  
          server_name  localhost;
  
          client_max_body_size 512M;
          fastcgi_buffers 64 4K;
  
          location / {
              root /var/www/nextcloud;
          rewrite ^ /index.php$request_uri;
          }
  
          location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
              deny all;
          }
          location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
              deny all;
          }
  
          location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
              fastcgi_split_path_info ^(.+?\.php)(/.*)$;
              include fastcgi_params;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              fastcgi_param PATH_INFO $fastcgi_path_info;
              fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
              fastcgi_intercept_errors on;
              fastcgi_request_buffering off;
          }
  
          location ~ ^/(?:updater|ocs-provider)(?:$|/) {
              try_files $uri/ =404;
              index index.php;
          }
  
          location ~ \.(?:css|js|woff|svg|gif)$ {
              try_files $uri /index.php$request_uri;
              add_header Cache-Control "public, max-age=15778463";
              access_log off;
          }
  
          location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
              try_files $uri /index.php$request_uri;
              # Optional: Don't log access to other assets
              access_log off;
          }
      }
  
  </code></pre>
  
  <p>And that of phpmyadmin:</p>
  
  <pre><code>
      server {
          listen 80;
          listen [::]:80;
  
          root /var/www/phpmyadmin/;
  
          # Add index.php to the list if you are using PHP
          index index.php index.html index.htm index.nginx-debian.html;
  
          server_name localhost;
  
          location / {
              # First attempt to serve request as file, then
              # as directory, then fall back to displaying a 404.
              try_files $uri $uri/ =404;
          }
  
          # pass PHP scripts to FastCGI server
          #
          location ~ \.php$ {
              include snippets/fastcgi-php.conf;
          #
          #   # With php-fpm (or other unix sockets):
              fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
          #   # With php-cgi (or other tcp sockets):
          #   fastcgi_pass 127.0.0.1:9000;
          }
      }
  
  </code></pre>
  
  <p>Try creating two test folders in /var/www/ (test1 and test2), each with an index.html file inside and modifying the nginx default file, but it didn't work for me either</p>
  
  <pre><code>    server {
          listen 80 default_server;
          listen [::]:80 default_server;
  
          server_name localhost;
  
          index index.html;
  
          location / {
              return 410;  # Default root of site won't exist.
          }
  
          location /test1/ {
              alias /var/www/test1/;
              try_files $uri $uri/ =404;
  
              # any additional configuration for non-static content
          }
  
          location /test2/ {
              alias /var/www/test2/;
              try_files $uri $uri/ =404;
  
              # any additional configuration for non-static content
          }
      }
  
  </code></pre>
  
  <p>As I said, I tried different solutions. Another problem I had was that it only redirected me to nextcloud, although I put phpmyadmin in the url. And the previous one that I already mentioned, that when I enter, download the index.php. Thank you.</p>
  
  <p>Sorry for my English.</p>