title: Nginx testing domains in localhost point to same root folder
body: <p>In trying test server config in localhost with fake domains but all show the same nginx html example.</p>
  
  <pre><code>server {
      listen 80 default_server;
      listen [::]:80 default_server;
  
      root /var/www/html;
  
      index index.html index.htm index.nginx-debian.html;
  
      server_name  test.localhost www.test.localhost;
  
  
      location / {
          try_files $uri $uri/ =404;
      }
  }
  </code></pre>
  
  <p>and the other config is there </p>
  
  <pre><code>server {
      listen 8080;
      listen [::]:8080 ;
  
      root /var/www/website;
      index index.php;
  
      server_name  website.localhost www.website.localhost;
  
      location / {
  
                  proxy_set_header X-Real-IP  $remote_addr;
                  proxy_set_header X-Forwarded-For $remote_addr;
                  proxy_set_header Host $host;
          try_files $uri $uri/ /index.php$is_args$args;
  
      }
  
      location ~ \.php$ {
  
          include snippets/fastcgi-php.conf;
          fastcgi_pass unix:/run/php/php7.4-fpm.sock;
      }
      location = /favicon.ico { log_not_found off; access_log off; }
      location = /robots.txt { log_not_found off; access_log off; allow all; }
      location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
          expires max;
          log_not_found off;
      }
      location ~ /\.ht { 
          deny all;
      }
  }
  </code></pre>
  
  <p>the second config is an simple wordpress setup, i can enter with normally using the usual localhost:8080 but if i try to enter with the domains all both show the first config content.</p>
  
  <p>I really don't know the reason why it happens, I'm not an expert in nginx.</p>