nginx delete location not found URL

221 Views Asked by At

By default, nginx returns an HTML page when a URL is specified that does not match any of the paths, and returns a 404. Is there a way to remove the HTML page generated and just return a 404 status code? I looked into the error_page directive but that seems to force you to have to specify a different HTML page

1

There are 1 best solutions below

0
On BEST ANSWER

You can use error_page to specify an empty file. In which case the Content-Length is zero and the Content-Type is based on the file's extension.

For example:

error_page 404 /empty.txt;