title: Custom 404 in Nginx
body: <p>I'm trying to specify a custom 404 page and preserve the URL, however using the below gives me the error <code>nginx: [emerg] "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or inside "limit_except" block in...</code></p>
  
  <pre><code>location / {
      error_page 404 @404;  
  }
  
  location @404 {
     proxy_pass https://example.com/404.html;
  }
  </code></pre>
  
  <p>Does anyone know a solution to this?</p>