title: Nginx Custom error page for Individual directory
body: <p>This my nginx configuration for 404 custom error page. But my problem is I'm getting custom 404 error page for all my 404 error that occurs in my server. I want to get custom error page for a particular directory only.</p>
  
  <pre><code>server {       
       listen 80 default_server;
       listen [::]:80 default_server;
  
      index index.html index.htm index.nginx-debian.html;
  
      server_name localhost;
  
      location / {
          root /var/www/html;
          try_files $uri $uri/ =404;
          }
  
      error_page 404 /fail.html;
  
      location = /fail.html {
          root /var/www/html/checking/errors;
          internal;
          }
      location /testing/([a-zA-Z]+)/ {
          root /var/www/html/testing/$1;
          try_files $uri $uri.html;
          }
      }
  </code></pre>