1e18a033bSKonstantin Ananyev
2e18a033bSKonstantin Ananyev/*
3e18a033bSKonstantin Ananyev * Copyright (C) Igor Sysoev
4e18a033bSKonstantin Ananyev * Copyright (C) Nginx, Inc.
5e18a033bSKonstantin Ananyev */
6e18a033bSKonstantin Ananyev
7e18a033bSKonstantin Ananyev
8e18a033bSKonstantin Ananyev#include <ngx_config.h>
9e18a033bSKonstantin Ananyev#include <ngx_core.h>
10e18a033bSKonstantin Ananyev#include <ngx_http.h>
11e18a033bSKonstantin Ananyev#include <nginx.h>
12e18a033bSKonstantin Ananyev
13e18a033bSKonstantin Ananyev
14e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_send_error_page(ngx_http_request_t *r,
15e18a033bSKonstantin Ananyev    ngx_http_err_page_t *err_page);
16e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_send_special_response(ngx_http_request_t *r,
17e18a033bSKonstantin Ananyev    ngx_http_core_loc_conf_t *clcf, ngx_uint_t err);
18e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_send_refresh(ngx_http_request_t *r);
19e18a033bSKonstantin Ananyev
20e18a033bSKonstantin Ananyev
21e18a033bSKonstantin Ananyevstatic u_char ngx_http_error_full_tail[] =
22e18a033bSKonstantin Ananyev"<hr><center>" NGINX_VER "</center>" CRLF
23e18a033bSKonstantin Ananyev"</body>" CRLF
24e18a033bSKonstantin Ananyev"</html>" CRLF
25e18a033bSKonstantin Ananyev;
26e18a033bSKonstantin Ananyev
27e18a033bSKonstantin Ananyev
28e18a033bSKonstantin Ananyevstatic u_char ngx_http_error_build_tail[] =
29e18a033bSKonstantin Ananyev"<hr><center>" NGINX_VER_BUILD "</center>" CRLF
30e18a033bSKonstantin Ananyev"</body>" CRLF
31e18a033bSKonstantin Ananyev"</html>" CRLF
32e18a033bSKonstantin Ananyev;
33e18a033bSKonstantin Ananyev
34e18a033bSKonstantin Ananyev
35e18a033bSKonstantin Ananyevstatic u_char ngx_http_error_tail[] =
36e18a033bSKonstantin Ananyev"<hr><center>nginx</center>" CRLF
37e18a033bSKonstantin Ananyev"</body>" CRLF
38e18a033bSKonstantin Ananyev"</html>" CRLF
39e18a033bSKonstantin Ananyev;
40e18a033bSKonstantin Ananyev
41e18a033bSKonstantin Ananyev
42e18a033bSKonstantin Ananyevstatic u_char ngx_http_msie_padding[] =
43e18a033bSKonstantin Ananyev"<!-- a padding to disable MSIE and Chrome friendly error page -->" CRLF
44e18a033bSKonstantin Ananyev"<!-- a padding to disable MSIE and Chrome friendly error page -->" CRLF
45e18a033bSKonstantin Ananyev"<!-- a padding to disable MSIE and Chrome friendly error page -->" CRLF
46e18a033bSKonstantin Ananyev"<!-- a padding to disable MSIE and Chrome friendly error page -->" CRLF
47e18a033bSKonstantin Ananyev"<!-- a padding to disable MSIE and Chrome friendly error page -->" CRLF
48e18a033bSKonstantin Ananyev"<!-- a padding to disable MSIE and Chrome friendly error page -->" CRLF
49e18a033bSKonstantin Ananyev;
50e18a033bSKonstantin Ananyev
51e18a033bSKonstantin Ananyev
52e18a033bSKonstantin Ananyevstatic u_char ngx_http_msie_refresh_head[] =
53e18a033bSKonstantin Ananyev"<html><head><meta http-equiv=\"Refresh\" content=\"0; URL=";
54e18a033bSKonstantin Ananyev
55e18a033bSKonstantin Ananyev
56e18a033bSKonstantin Ananyevstatic u_char ngx_http_msie_refresh_tail[] =
57e18a033bSKonstantin Ananyev"\"></head><body></body></html>" CRLF;
58e18a033bSKonstantin Ananyev
59e18a033bSKonstantin Ananyev
60e18a033bSKonstantin Ananyevstatic char ngx_http_error_301_page[] =
61e18a033bSKonstantin Ananyev"<html>" CRLF
62e18a033bSKonstantin Ananyev"<head><title>301 Moved Permanently</title></head>" CRLF
63e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
64e18a033bSKonstantin Ananyev"<center><h1>301 Moved Permanently</h1></center>" CRLF
65e18a033bSKonstantin Ananyev;
66e18a033bSKonstantin Ananyev
67e18a033bSKonstantin Ananyev
68e18a033bSKonstantin Ananyevstatic char ngx_http_error_302_page[] =
69e18a033bSKonstantin Ananyev"<html>" CRLF
70e18a033bSKonstantin Ananyev"<head><title>302 Found</title></head>" CRLF
71e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
72e18a033bSKonstantin Ananyev"<center><h1>302 Found</h1></center>" CRLF
73e18a033bSKonstantin Ananyev;
74e18a033bSKonstantin Ananyev
75e18a033bSKonstantin Ananyev
76e18a033bSKonstantin Ananyevstatic char ngx_http_error_303_page[] =
77e18a033bSKonstantin Ananyev"<html>" CRLF
78e18a033bSKonstantin Ananyev"<head><title>303 See Other</title></head>" CRLF
79e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
80e18a033bSKonstantin Ananyev"<center><h1>303 See Other</h1></center>" CRLF
81e18a033bSKonstantin Ananyev;
82e18a033bSKonstantin Ananyev
83e18a033bSKonstantin Ananyev
84e18a033bSKonstantin Ananyevstatic char ngx_http_error_307_page[] =
85e18a033bSKonstantin Ananyev"<html>" CRLF
86e18a033bSKonstantin Ananyev"<head><title>307 Temporary Redirect</title></head>" CRLF
87e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
88e18a033bSKonstantin Ananyev"<center><h1>307 Temporary Redirect</h1></center>" CRLF
89e18a033bSKonstantin Ananyev;
90e18a033bSKonstantin Ananyev
91e18a033bSKonstantin Ananyev
92e18a033bSKonstantin Ananyevstatic char ngx_http_error_400_page[] =
93e18a033bSKonstantin Ananyev"<html>" CRLF
94e18a033bSKonstantin Ananyev"<head><title>400 Bad Request</title></head>" CRLF
95e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
96e18a033bSKonstantin Ananyev"<center><h1>400 Bad Request</h1></center>" CRLF
97e18a033bSKonstantin Ananyev;
98e18a033bSKonstantin Ananyev
99e18a033bSKonstantin Ananyev
100e18a033bSKonstantin Ananyevstatic char ngx_http_error_401_page[] =
101e18a033bSKonstantin Ananyev"<html>" CRLF
102e18a033bSKonstantin Ananyev"<head><title>401 Authorization Required</title></head>" CRLF
103e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
104e18a033bSKonstantin Ananyev"<center><h1>401 Authorization Required</h1></center>" CRLF
105e18a033bSKonstantin Ananyev;
106e18a033bSKonstantin Ananyev
107e18a033bSKonstantin Ananyev
108e18a033bSKonstantin Ananyevstatic char ngx_http_error_402_page[] =
109e18a033bSKonstantin Ananyev"<html>" CRLF
110e18a033bSKonstantin Ananyev"<head><title>402 Payment Required</title></head>" CRLF
111e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
112e18a033bSKonstantin Ananyev"<center><h1>402 Payment Required</h1></center>" CRLF
113e18a033bSKonstantin Ananyev;
114e18a033bSKonstantin Ananyev
115e18a033bSKonstantin Ananyev
116e18a033bSKonstantin Ananyevstatic char ngx_http_error_403_page[] =
117e18a033bSKonstantin Ananyev"<html>" CRLF
118e18a033bSKonstantin Ananyev"<head><title>403 Forbidden</title></head>" CRLF
119e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
120e18a033bSKonstantin Ananyev"<center><h1>403 Forbidden</h1></center>" CRLF
121e18a033bSKonstantin Ananyev;
122e18a033bSKonstantin Ananyev
123e18a033bSKonstantin Ananyev
124e18a033bSKonstantin Ananyevstatic char ngx_http_error_404_page[] =
125e18a033bSKonstantin Ananyev"<html>" CRLF
126e18a033bSKonstantin Ananyev"<head><title>404 Not Found</title></head>" CRLF
127e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
128e18a033bSKonstantin Ananyev"<center><h1>404 Not Found</h1></center>" CRLF
129e18a033bSKonstantin Ananyev;
130e18a033bSKonstantin Ananyev
131e18a033bSKonstantin Ananyev
132e18a033bSKonstantin Ananyevstatic char ngx_http_error_405_page[] =
133e18a033bSKonstantin Ananyev"<html>" CRLF
134e18a033bSKonstantin Ananyev"<head><title>405 Not Allowed</title></head>" CRLF
135e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
136e18a033bSKonstantin Ananyev"<center><h1>405 Not Allowed</h1></center>" CRLF
137e18a033bSKonstantin Ananyev;
138e18a033bSKonstantin Ananyev
139e18a033bSKonstantin Ananyev
140e18a033bSKonstantin Ananyevstatic char ngx_http_error_406_page[] =
141e18a033bSKonstantin Ananyev"<html>" CRLF
142e18a033bSKonstantin Ananyev"<head><title>406 Not Acceptable</title></head>" CRLF
143e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
144e18a033bSKonstantin Ananyev"<center><h1>406 Not Acceptable</h1></center>" CRLF
145e18a033bSKonstantin Ananyev;
146e18a033bSKonstantin Ananyev
147e18a033bSKonstantin Ananyev
148e18a033bSKonstantin Ananyevstatic char ngx_http_error_408_page[] =
149e18a033bSKonstantin Ananyev"<html>" CRLF
150e18a033bSKonstantin Ananyev"<head><title>408 Request Time-out</title></head>" CRLF
151e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
152e18a033bSKonstantin Ananyev"<center><h1>408 Request Time-out</h1></center>" CRLF
153e18a033bSKonstantin Ananyev;
154e18a033bSKonstantin Ananyev
155e18a033bSKonstantin Ananyev
156e18a033bSKonstantin Ananyevstatic char ngx_http_error_409_page[] =
157e18a033bSKonstantin Ananyev"<html>" CRLF
158e18a033bSKonstantin Ananyev"<head><title>409 Conflict</title></head>" CRLF
159e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
160e18a033bSKonstantin Ananyev"<center><h1>409 Conflict</h1></center>" CRLF
161e18a033bSKonstantin Ananyev;
162e18a033bSKonstantin Ananyev
163e18a033bSKonstantin Ananyev
164e18a033bSKonstantin Ananyevstatic char ngx_http_error_410_page[] =
165e18a033bSKonstantin Ananyev"<html>" CRLF
166e18a033bSKonstantin Ananyev"<head><title>410 Gone</title></head>" CRLF
167e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
168e18a033bSKonstantin Ananyev"<center><h1>410 Gone</h1></center>" CRLF
169e18a033bSKonstantin Ananyev;
170e18a033bSKonstantin Ananyev
171e18a033bSKonstantin Ananyev
172e18a033bSKonstantin Ananyevstatic char ngx_http_error_411_page[] =
173e18a033bSKonstantin Ananyev"<html>" CRLF
174e18a033bSKonstantin Ananyev"<head><title>411 Length Required</title></head>" CRLF
175e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
176e18a033bSKonstantin Ananyev"<center><h1>411 Length Required</h1></center>" CRLF
177e18a033bSKonstantin Ananyev;
178e18a033bSKonstantin Ananyev
179e18a033bSKonstantin Ananyev
180e18a033bSKonstantin Ananyevstatic char ngx_http_error_412_page[] =
181e18a033bSKonstantin Ananyev"<html>" CRLF
182e18a033bSKonstantin Ananyev"<head><title>412 Precondition Failed</title></head>" CRLF
183e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
184e18a033bSKonstantin Ananyev"<center><h1>412 Precondition Failed</h1></center>" CRLF
185e18a033bSKonstantin Ananyev;
186e18a033bSKonstantin Ananyev
187e18a033bSKonstantin Ananyev
188e18a033bSKonstantin Ananyevstatic char ngx_http_error_413_page[] =
189e18a033bSKonstantin Ananyev"<html>" CRLF
190e18a033bSKonstantin Ananyev"<head><title>413 Request Entity Too Large</title></head>" CRLF
191e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
192e18a033bSKonstantin Ananyev"<center><h1>413 Request Entity Too Large</h1></center>" CRLF
193e18a033bSKonstantin Ananyev;
194e18a033bSKonstantin Ananyev
195e18a033bSKonstantin Ananyev
196e18a033bSKonstantin Ananyevstatic char ngx_http_error_414_page[] =
197e18a033bSKonstantin Ananyev"<html>" CRLF
198e18a033bSKonstantin Ananyev"<head><title>414 Request-URI Too Large</title></head>" CRLF
199e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
200e18a033bSKonstantin Ananyev"<center><h1>414 Request-URI Too Large</h1></center>" CRLF
201e18a033bSKonstantin Ananyev;
202e18a033bSKonstantin Ananyev
203e18a033bSKonstantin Ananyev
204e18a033bSKonstantin Ananyevstatic char ngx_http_error_415_page[] =
205e18a033bSKonstantin Ananyev"<html>" CRLF
206e18a033bSKonstantin Ananyev"<head><title>415 Unsupported Media Type</title></head>" CRLF
207e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
208e18a033bSKonstantin Ananyev"<center><h1>415 Unsupported Media Type</h1></center>" CRLF
209e18a033bSKonstantin Ananyev;
210e18a033bSKonstantin Ananyev
211e18a033bSKonstantin Ananyev
212e18a033bSKonstantin Ananyevstatic char ngx_http_error_416_page[] =
213e18a033bSKonstantin Ananyev"<html>" CRLF
214e18a033bSKonstantin Ananyev"<head><title>416 Requested Range Not Satisfiable</title></head>" CRLF
215e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
216e18a033bSKonstantin Ananyev"<center><h1>416 Requested Range Not Satisfiable</h1></center>" CRLF
217e18a033bSKonstantin Ananyev;
218e18a033bSKonstantin Ananyev
219e18a033bSKonstantin Ananyev
220e18a033bSKonstantin Ananyevstatic char ngx_http_error_421_page[] =
221e18a033bSKonstantin Ananyev"<html>" CRLF
222e18a033bSKonstantin Ananyev"<head><title>421 Misdirected Request</title></head>" CRLF
223e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
224e18a033bSKonstantin Ananyev"<center><h1>421 Misdirected Request</h1></center>" CRLF
225e18a033bSKonstantin Ananyev;
226e18a033bSKonstantin Ananyev
227e18a033bSKonstantin Ananyev
228e18a033bSKonstantin Ananyevstatic char ngx_http_error_429_page[] =
229e18a033bSKonstantin Ananyev"<html>" CRLF
230e18a033bSKonstantin Ananyev"<head><title>429 Too Many Requests</title></head>" CRLF
231e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
232e18a033bSKonstantin Ananyev"<center><h1>429 Too Many Requests</h1></center>" CRLF
233e18a033bSKonstantin Ananyev;
234e18a033bSKonstantin Ananyev
235e18a033bSKonstantin Ananyev
236e18a033bSKonstantin Ananyevstatic char ngx_http_error_494_page[] =
237e18a033bSKonstantin Ananyev"<html>" CRLF
238e18a033bSKonstantin Ananyev"<head><title>400 Request Header Or Cookie Too Large</title></head>"
239e18a033bSKonstantin AnanyevCRLF
240e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
241e18a033bSKonstantin Ananyev"<center><h1>400 Bad Request</h1></center>" CRLF
242e18a033bSKonstantin Ananyev"<center>Request Header Or Cookie Too Large</center>" CRLF
243e18a033bSKonstantin Ananyev;
244e18a033bSKonstantin Ananyev
245e18a033bSKonstantin Ananyev
246e18a033bSKonstantin Ananyevstatic char ngx_http_error_495_page[] =
247e18a033bSKonstantin Ananyev"<html>" CRLF
248e18a033bSKonstantin Ananyev"<head><title>400 The SSL certificate error</title></head>"
249e18a033bSKonstantin AnanyevCRLF
250e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
251e18a033bSKonstantin Ananyev"<center><h1>400 Bad Request</h1></center>" CRLF
252e18a033bSKonstantin Ananyev"<center>The SSL certificate error</center>" CRLF
253e18a033bSKonstantin Ananyev;
254e18a033bSKonstantin Ananyev
255e18a033bSKonstantin Ananyev
256e18a033bSKonstantin Ananyevstatic char ngx_http_error_496_page[] =
257e18a033bSKonstantin Ananyev"<html>" CRLF
258e18a033bSKonstantin Ananyev"<head><title>400 No required SSL certificate was sent</title></head>"
259e18a033bSKonstantin AnanyevCRLF
260e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
261e18a033bSKonstantin Ananyev"<center><h1>400 Bad Request</h1></center>" CRLF
262e18a033bSKonstantin Ananyev"<center>No required SSL certificate was sent</center>" CRLF
263e18a033bSKonstantin Ananyev;
264e18a033bSKonstantin Ananyev
265e18a033bSKonstantin Ananyev
266e18a033bSKonstantin Ananyevstatic char ngx_http_error_497_page[] =
267e18a033bSKonstantin Ananyev"<html>" CRLF
268e18a033bSKonstantin Ananyev"<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>"
269e18a033bSKonstantin AnanyevCRLF
270e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
271e18a033bSKonstantin Ananyev"<center><h1>400 Bad Request</h1></center>" CRLF
272e18a033bSKonstantin Ananyev"<center>The plain HTTP request was sent to HTTPS port</center>" CRLF
273e18a033bSKonstantin Ananyev;
274e18a033bSKonstantin Ananyev
275e18a033bSKonstantin Ananyev
276e18a033bSKonstantin Ananyevstatic char ngx_http_error_500_page[] =
277e18a033bSKonstantin Ananyev"<html>" CRLF
278e18a033bSKonstantin Ananyev"<head><title>500 Internal Server Error</title></head>" CRLF
279e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
280e18a033bSKonstantin Ananyev"<center><h1>500 Internal Server Error</h1></center>" CRLF
281e18a033bSKonstantin Ananyev;
282e18a033bSKonstantin Ananyev
283e18a033bSKonstantin Ananyev
284e18a033bSKonstantin Ananyevstatic char ngx_http_error_501_page[] =
285e18a033bSKonstantin Ananyev"<html>" CRLF
286e18a033bSKonstantin Ananyev"<head><title>501 Not Implemented</title></head>" CRLF
287e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
288e18a033bSKonstantin Ananyev"<center><h1>501 Not Implemented</h1></center>" CRLF
289e18a033bSKonstantin Ananyev;
290e18a033bSKonstantin Ananyev
291e18a033bSKonstantin Ananyev
292e18a033bSKonstantin Ananyevstatic char ngx_http_error_502_page[] =
293e18a033bSKonstantin Ananyev"<html>" CRLF
294e18a033bSKonstantin Ananyev"<head><title>502 Bad Gateway</title></head>" CRLF
295e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
296e18a033bSKonstantin Ananyev"<center><h1>502 Bad Gateway</h1></center>" CRLF
297e18a033bSKonstantin Ananyev;
298e18a033bSKonstantin Ananyev
299e18a033bSKonstantin Ananyev
300e18a033bSKonstantin Ananyevstatic char ngx_http_error_503_page[] =
301e18a033bSKonstantin Ananyev"<html>" CRLF
302e18a033bSKonstantin Ananyev"<head><title>503 Service Temporarily Unavailable</title></head>" CRLF
303e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
304e18a033bSKonstantin Ananyev"<center><h1>503 Service Temporarily Unavailable</h1></center>" CRLF
305e18a033bSKonstantin Ananyev;
306e18a033bSKonstantin Ananyev
307e18a033bSKonstantin Ananyev
308e18a033bSKonstantin Ananyevstatic char ngx_http_error_504_page[] =
309e18a033bSKonstantin Ananyev"<html>" CRLF
310e18a033bSKonstantin Ananyev"<head><title>504 Gateway Time-out</title></head>" CRLF
311e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
312e18a033bSKonstantin Ananyev"<center><h1>504 Gateway Time-out</h1></center>" CRLF
313e18a033bSKonstantin Ananyev;
314e18a033bSKonstantin Ananyev
315e18a033bSKonstantin Ananyev
316e18a033bSKonstantin Ananyevstatic char ngx_http_error_507_page[] =
317e18a033bSKonstantin Ananyev"<html>" CRLF
318e18a033bSKonstantin Ananyev"<head><title>507 Insufficient Storage</title></head>" CRLF
319e18a033bSKonstantin Ananyev"<body bgcolor=\"white\">" CRLF
320e18a033bSKonstantin Ananyev"<center><h1>507 Insufficient Storage</h1></center>" CRLF
321e18a033bSKonstantin Ananyev;
322e18a033bSKonstantin Ananyev
323e18a033bSKonstantin Ananyev
324e18a033bSKonstantin Ananyevstatic ngx_str_t ngx_http_error_pages[] = {
325e18a033bSKonstantin Ananyev
326e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 201, 204 */
327e18a033bSKonstantin Ananyev
328e18a033bSKonstantin Ananyev#define NGX_HTTP_LAST_2XX  202
329e18a033bSKonstantin Ananyev#define NGX_HTTP_OFF_3XX   (NGX_HTTP_LAST_2XX - 201)
330e18a033bSKonstantin Ananyev
331e18a033bSKonstantin Ananyev    /* ngx_null_string, */               /* 300 */
332e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_301_page),
333e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_302_page),
334e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_303_page),
335e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 304 */
336e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 305 */
337e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 306 */
338e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_307_page),
339e18a033bSKonstantin Ananyev
340e18a033bSKonstantin Ananyev#define NGX_HTTP_LAST_3XX  308
341e18a033bSKonstantin Ananyev#define NGX_HTTP_OFF_4XX   (NGX_HTTP_LAST_3XX - 301 + NGX_HTTP_OFF_3XX)
342e18a033bSKonstantin Ananyev
343e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_400_page),
344e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_401_page),
345e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_402_page),
346e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_403_page),
347e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_404_page),
348e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_405_page),
349e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_406_page),
350e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 407 */
351e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_408_page),
352e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_409_page),
353e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_410_page),
354e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_411_page),
355e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_412_page),
356e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_413_page),
357e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_414_page),
358e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_415_page),
359e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_416_page),
360e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 417 */
361e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 418 */
362e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 419 */
363e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 420 */
364e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_421_page),
365e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 422 */
366e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 423 */
367e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 424 */
368e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 425 */
369e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 426 */
370e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 427 */
371e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 428 */
372e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_429_page),
373e18a033bSKonstantin Ananyev
374e18a033bSKonstantin Ananyev#define NGX_HTTP_LAST_4XX  430
375e18a033bSKonstantin Ananyev#define NGX_HTTP_OFF_5XX   (NGX_HTTP_LAST_4XX - 400 + NGX_HTTP_OFF_4XX)
376e18a033bSKonstantin Ananyev
377e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_494_page), /* 494, request header too large */
378e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_495_page), /* 495, https certificate error */
379e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_496_page), /* 496, https no certificate */
380e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_497_page), /* 497, http to https */
381e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_404_page), /* 498, canceled */
382e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 499, client has closed connection */
383e18a033bSKonstantin Ananyev
384e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_500_page),
385e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_501_page),
386e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_502_page),
387e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_503_page),
388e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_504_page),
389e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 505 */
390e18a033bSKonstantin Ananyev    ngx_null_string,                     /* 506 */
391e18a033bSKonstantin Ananyev    ngx_string(ngx_http_error_507_page)
392e18a033bSKonstantin Ananyev
393e18a033bSKonstantin Ananyev#define NGX_HTTP_LAST_5XX  508
394e18a033bSKonstantin Ananyev
395e18a033bSKonstantin Ananyev};
396e18a033bSKonstantin Ananyev
397e18a033bSKonstantin Ananyev
398e18a033bSKonstantin Ananyevngx_int_t
399e18a033bSKonstantin Ananyevngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
400e18a033bSKonstantin Ananyev{
401e18a033bSKonstantin Ananyev    ngx_uint_t                 i, err;
402e18a033bSKonstantin Ananyev    ngx_http_err_page_t       *err_page;
403e18a033bSKonstantin Ananyev    ngx_http_core_loc_conf_t  *clcf;
404e18a033bSKonstantin Ananyev
405e18a033bSKonstantin Ananyev    ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
406e18a033bSKonstantin Ananyev                   "http special response: %i, \"%V?%V\"",
407e18a033bSKonstantin Ananyev                   error, &r->uri, &r->args);
408e18a033bSKonstantin Ananyev
409e18a033bSKonstantin Ananyev    r->err_status = error;
410e18a033bSKonstantin Ananyev
411e18a033bSKonstantin Ananyev    if (r->keepalive) {
412e18a033bSKonstantin Ananyev        switch (error) {
413e18a033bSKonstantin Ananyev            case NGX_HTTP_BAD_REQUEST:
414e18a033bSKonstantin Ananyev            case NGX_HTTP_REQUEST_ENTITY_TOO_LARGE:
415e18a033bSKonstantin Ananyev            case NGX_HTTP_REQUEST_URI_TOO_LARGE:
416e18a033bSKonstantin Ananyev            case NGX_HTTP_TO_HTTPS:
417e18a033bSKonstantin Ananyev            case NGX_HTTPS_CERT_ERROR:
418