title: nginx is serving pages for requests for bare IP address (which doesn't match the server_name)
body: <p>I have an nginx configuration with two virtual hosts and no default site.</p>
  
  <pre><code>server {
    listen 123.45.67.89:80;
    server_name site_a.example.com site_a1.example.com;
  
    root /srv/site_a_checkout/html/site_a;
    access_log /var/log/site_a/nginx.access.log;
    error_log /var/log/site_a/nginx.error.log;
  
    index index.html index.htm index.nginx-debian.html;
  
    location / {
      # First attempt to serve request as file, then
      # as directory, then fall back to displaying a 404.
      try_files $uri $uri/ =404;
    }
  }
  </code></pre>
  
  <p>Each of the virtual host configurations has a <code>server_name</code> line with two servers.  </p>
  
  <p>The existence of the second server_name, <code>site_a1.example.com</code>, is because there is more than one server and sometimes developers need to know which server they're looking at.</p>
  
  <p>nginx performs exactly as expected, if <code>http://site_a.example.com</code>, <code>http://site_a1.example1.com</code>, <code>http://site_b.example.com</code> or <code>http://site_b1.example1.com</code> are requested.</p>
  
  <p>The problem is that if <code>http://123.45.67.89</code> is requested, the <code>site_a</code> site is served.</p>
  
  <p>There is no <code>/etc/nginx/sites_enabled/default</code>, only virtual hosts for site_a and site_b.</p>
  
  <p>Why is site_a served as <code>http://123.45.67.89</code>?</p>
  
  <p>How can I make requests to the IP address fail?</p>
  
  <hr>
  
  <p>I've also tried: <a href="https://superuser.com/a/1050864">https://superuser.com/a/1050864</a> and <a href="https://serverfault.com/a/525011">https://serverfault.com/a/525011</a> but these did not work either. </p>