title: render custom 404 in nginx or something else if 404 doesn't exist
body: <p>I'd like to host HTML files uploaded by users and I need to display custom 404 if they provided it, or display my own 404 otherwise.</p>
  <p>Sample workflow:</p>
  <ol>
  <li>visitor tries to access example.com/pages/page1.html</li>
  <li><code>pages/page1.html</code> does not exists but $user has uploaded <code>404.html</code> so display it</li>
  <li>$user has not provided <code>404.html</code> so display simple message myself</li>
  </ol>
  <p>So far I have covered the steps 1 &amp; 2 but cannot make the logic for last one.</p>
  <p>My /simplified/ config:</p>
  <pre><code># each user has their own storage path etc
  # just to illustrate
  map $host $user {
      dog.example.com             group/1/2/3;
      cat.example.com             group/4/5/1;
      dog-want-cookie.example.com group/9/9/9;
  }
  
  server {
      listen 8000;
      server_name ~^(?&lt;vhost&gt;[^.]*)\.example\.com$;
  
      root /sites/$user;
  
      location / {        
          try_files $uri $uri/index.html @not_found;
      }
  
      location @not_found {
          internal;
          error_page 404 /404.html;
      }
  }
  </code></pre>
  <p>Not sure where to &quot;invoke&quot; a config for my own error &quot;page&quot;.</p>
  <pre><code>location @my404 {
      return 404 &quot;Page not found.&quot;;
  }
  </code></pre>
  <p>I'm using Nginx 1.19.3 on Debian.</p>