How do I show a 403 error page when the server returns a 403 error code? I use the nginx config file from https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/
It has return 403 and deny all on some file.
Ex. When I visit /core/CHANGELOG.txt, nginx returns default 403 Forbidden page.
I want it to display drupal 403 error page not nginx white default 403 page.
I have tried adding error_page 403 /403  but it returns

Not Found
The requested URL &quot;http://mysite/core/CHANGELOG.txt&quot; was not found on this server.
What you need to do is to configure nginx to serve a drupal page that generates a 403 page. There are severals ways to do this.

The easy solution is to route the traffic to Drupal (the index.php file), which would generate a 404 since the page doesn't exist in Drupal.

I think doing

location ~* \.(txt|log)$ {
  try_files @rewrite
}


should accomplish this for .txt and .log files. It should try to serve the file from Drupal. By default this will be a 404, but you can add the a route for specific files and return 403 instead.