title: How to setup custom 503 error page in Nginx that intercepts all requests?
body: <p>I learned how to get NGINX to return <code>503</code> customer error pages,
  but I cannot find out how to do the following:</p>
  
  <p>Sample config file:</p>
  
  <pre><code>    location / {
          root   www;
          index  index.php;
          try_files /503.html =503;
      }
  
      error_page 503 /503.html;
      location = /503.html {
          root   www;
      }
  </code></pre>
  
  <p>As you can see, according to the code above, if a page called <code>503.html</code> is found in my root directory, the site will return this page to the user. </p>
  
  <p><strong>But</strong> it seems that although the code above works when someone simply visits my site typing </p>
  
  <ul>
  <li><a href="http://www.example.com" rel="nofollow noreferrer">http://www.example.com</a></li>
  </ul>
  
  <p><em>it does not trap requests like:</em></p>
  
  <ul>
  <li><a href="http://www.example.com/profile.php" rel="nofollow noreferrer">http://www.example.com/profile.php</a></li>
  </ul>
  
  <p>With my code, the user can still see the profile page or any other pages besides <code>index.php</code>.</p>
  
  <p>The question:</p>
  
  <p>How do I trap requests to all pages in my site and forward them to <code>503.html</code> whenever <code>503.html</code> is present in my root folder?</p>