Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does nginx store default error pages

Tags:

nginx

Where does nginx store the default error pages it outputs on disk? I.E. the standard 404 looking like:

404 Not Found

404 Not Found


nginx

Hopefully these are not hard-coded into the nginx source. Thanks.

like image 433
Justin Avatar asked Nov 19 '12 02:11

Justin


People also ask

Where are Nginx default error pages?

Creating Your Custom Error Pages Put your custom error pages in the /usr/share/nginx/html directory where Nginx sets its default document root.

Where is Nginx error 404?

conf under /etc/nginx/snippets/ as shown. This configuration causes an internal redirect to the URI/error-page. html every time NGINX encounters any of the specified HTTP errors 404, 403, 500, and 503. The location context tells NGINX where to find your error page.

Where are Nginx files stored?

Every NGINX configuration file will be found in the /etc/nginx/ directory, with the main configuration file located in /etc/nginx/nginx. conf .


1 Answers

Check out html folder in the nginx directory - there should be 50x pages.

By default, I believe, all "special pages", including 404 page are hardcoded

static char ngx_http_error_404_page[] =
"<html>" CRLF
"<head><title>404 Not Found</title></head>" CRLF
"<body>" CRLF
"<center><h1>404 Not Found</h1></center>" CRLF
;

Source: https://github.com/nginx/nginx/blob/release-1.15.8/src/http/ngx_http_special_response.c#L132

but can be customized:

server {
    ...
    error_page 404 /404.html;
    ...
}
like image 135
Dmitry Frenkel Avatar answered Sep 17 '22 15:09

Dmitry Frenkel