title: nginx: how to always return a custom 404 page for the default host
body: <p>I have nginx 0.8.53 configured with some virtual hosts which work as desired. However, due to nginx's &quot;best match&quot; on virtual hosts, I need to add a default host to catch all requests that aren't for a specific virtual host.  I would like the default host to return a custom 404 page that I created instead of the default nginx 404 page.</p>
  <p>I assumed I needed something like:</p>
  <pre><code># The default server:
  server {
      listen       80 default_server;
      server_name  everythingelse;
  
      # Everything is a 404
      location / {
          return 404;
      }
      error_page 404 /opt/local/html/404.html;
  }
  </code></pre>
  <p>But this still returns the default nginx 404 page.  It seems the <code>return 404</code> ignores the <code>error_page</code> config.</p>