Hands-on task
Custom 404 Page
Configure nginx (port 80): when a non-existent path is requested, it must return its own error page with the text Page not found and status 404.
- nginx
- error_page
- location
- docroot
- http statuses
Hands-on task
Configure nginx (port 80): when a non-existent path is requested, it must return its own error page with the text Page not found and status 404.
nginx lets you replace standard error pages with your own via the error_page directive, which ties a response code to an internal resource. The page file itself is placed in the site root (docroot), and access to it is restricted with a separate location using an exact match and the internal marker — so the page is served only as a response to an error, not by a direct request. Important to understand: replacing the body doesn't change the HTTP status — the client still receives the original error code. After editing, the config is checked (nginx -t) and reread without stopping the server.