Hello!
The following two patches make it so that whenever nginx provides an
autoindexed page or a special response page, the HTML page sent uses
valid HTML.
This means browsers will use a standards-compliant mode rather than
quirks mode to render those pages.
Thanks for reading!
--- oldnginx-1.15.6/src/http/ngx_http_special_response.c 2018-11-06 08:32:09.000000000 -0500
+++ nginx-1.15.6/src/http/ngx_http_special_response.c 2018-11-26 22:17:48.582442698 -0500
@@ -19,21 +19,21 @@
static u_char ngx_http_error_full_tail[] =
-"<hr><center>" NGINX_VER "</center>" CRLF
+"<hr><p>" NGINX_VER "</p>" CRLF
"</body>" CRLF
"</html>" CRLF
;
static u_char ngx_http_error_build_tail[] =
-"<hr><center>" NGINX_VER_BUILD "</center>" CRLF
+"<hr><p>" NGINX_VER_BUILD "</p>" CRLF
"</body>" CRLF
"</html>" CRLF
;
static u_char ngx_http_error_tail[] =
-"<hr><center>nginx</center>" CRLF
+"<hr><p>nginx</p>" CRLF
"</body>" CRLF
"</html>" CRLF
;
@@ -58,282 +58,316 @@
static char ngx_http_error_301_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>301 Moved Permanently</title></head>" CRLF
"<body>" CRLF
-"<center><h1>301 Moved Permanently</h1></center>" CRLF
+"<h1>301 Moved Permanently</h1>" CRLF
;
static char ngx_http_error_302_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>302 Found</title></head>" CRLF
"<body>" CRLF
-"<center><h1>302 Found</h1></center>" CRLF
+"<h1>302 Found</h1>" CRLF
;
static char ngx_http_error_303_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>303 See Other</title></head>" CRLF
"<body>" CRLF
-"<center><h1>303 See Other</h1></center>" CRLF
+"<h1>303 See Other</h1>" CRLF
;
static char ngx_http_error_307_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>307 Temporary Redirect</title></head>" CRLF
"<body>" CRLF
-"<center><h1>307 Temporary Redirect</h1></center>" CRLF
+"<h1>307 Temporary Redirect</h1>" CRLF
;
static char ngx_http_error_308_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>308 Permanent Redirect</title></head>" CRLF
"<body>" CRLF
-"<center><h1>308 Permanent Redirect</h1></center>" CRLF
+"<h1>308 Permanent Redirect</h1>" CRLF
;
static char ngx_http_error_400_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>400 Bad Request</title></head>" CRLF
"<body>" CRLF
-"<center><h1>400 Bad Request</h1></center>" CRLF
+"<h1>400 Bad Request</h1>" CRLF
;
static char ngx_http_error_401_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>401 Authorization Required</title></head>" CRLF
"<body>" CRLF
-"<center><h1>401 Authorization Required</h1></center>" CRLF
+"<h1>401 Authorization Required</h1>" CRLF
;
static char ngx_http_error_402_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>402 Payment Required</title></head>" CRLF
"<body>" CRLF
-"<center><h1>402 Payment Required</h1></center>" CRLF
+"<h1>402 Payment Required</h1>" CRLF
;
static char ngx_http_error_403_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>403 Forbidden</title></head>" CRLF
"<body>" CRLF
-"<center><h1>403 Forbidden</h1></center>" CRLF
+"<h1>403 Forbidden</h1>" CRLF
;
static char ngx_http_error_404_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>404 Not Found</title></head>" CRLF
"<body>" CRLF
-"<center><h1>404 Not Found</h1></center>" CRLF
+"<h1>404 Not Found</h1>" CRLF
;
static char ngx_http_error_405_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>405 Not Allowed</title></head>" CRLF
"<body>" CRLF
-"<center><h1>405 Not Allowed</h1></center>" CRLF
+"<h1>405 Not Allowed</h1>" CRLF
;
static char ngx_http_error_406_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>406 Not Acceptable</title></head>" CRLF
"<body>" CRLF
-"<center><h1>406 Not Acceptable</h1></center>" CRLF
+"<h1>406 Not Acceptable</h1>" CRLF
;
static char ngx_http_error_408_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>408 Request Time-out</title></head>" CRLF
"<body>" CRLF
-"<center><h1>408 Request Time-out</h1></center>" CRLF
+"<h1>408 Request Time-out</h1>" CRLF
;
static char ngx_http_error_409_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>409 Conflict</title></head>" CRLF
"<body>" CRLF
-"<center><h1>409 Conflict</h1></center>" CRLF
+"<h1>409 Conflict</h1>" CRLF
;
static char ngx_http_error_410_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>410 Gone</title></head>" CRLF
"<body>" CRLF
-"<center><h1>410 Gone</h1></center>" CRLF
+"<h1>410 Gone</h1>" CRLF
;
static char ngx_http_error_411_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>411 Length Required</title></head>" CRLF
"<body>" CRLF
-"<center><h1>411 Length Required</h1></center>" CRLF
+"<h1>411 Length Required</h1>" CRLF
;
static char ngx_http_error_412_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>412 Precondition Failed</title></head>" CRLF
"<body>" CRLF
-"<center><h1>412 Precondition Failed</h1></center>" CRLF
+"<h1>412 Precondition Failed</h1>" CRLF
;
static char ngx_http_error_413_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>413 Request Entity Too Large</title></head>" CRLF
"<body>" CRLF
-"<center><h1>413 Request Entity Too Large</h1></center>" CRLF
+"<h1>413 Request Entity Too Large</h1>" CRLF
;
static char ngx_http_error_414_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>414 Request-URI Too Large</title></head>" CRLF
"<body>" CRLF
-"<center><h1>414 Request-URI Too Large</h1></center>" CRLF
+"<h1>414 Request-URI Too Large</h1>" CRLF
;
static char ngx_http_error_415_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>415 Unsupported Media Type</title></head>" CRLF
"<body>" CRLF
-"<center><h1>415 Unsupported Media Type</h1></center>" CRLF
+"<h1>415 Unsupported Media Type</h1>" CRLF
;
static char ngx_http_error_416_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>416 Requested Range Not Satisfiable</title></head>" CRLF
"<body>" CRLF
-"<center><h1>416 Requested Range Not Satisfiable</h1></center>" CRLF
+"<h1>416 Requested Range Not Satisfiable</h1>" CRLF
;
static char ngx_http_error_421_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>421 Misdirected Request</title></head>" CRLF
"<body>" CRLF
-"<center><h1>421 Misdirected Request</h1></center>" CRLF
+"<h1>421 Misdirected Request</h1>" CRLF
;
static char ngx_http_error_429_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>429 Too Many Requests</title></head>" CRLF
"<body>" CRLF
-"<center><h1>429 Too Many Requests</h1></center>" CRLF
+"<h1>429 Too Many Requests</h1>" CRLF
;
static char ngx_http_error_494_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>400 Request Header Or Cookie Too Large</title></head>"
CRLF
"<body>" CRLF
-"<center><h1>400 Bad Request</h1></center>" CRLF
-"<center>Request Header Or Cookie Too Large</center>" CRLF
+"<h1>400 Bad Request</h1>" CRLF
+"<p>Request Header Or Cookie Too Large</p>" CRLF
;
static char ngx_http_error_495_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>400 The SSL certificate error</title></head>"
CRLF
"<body>" CRLF
-"<center><h1>400 Bad Request</h1></center>" CRLF
-"<center>The SSL certificate error</center>" CRLF
+"<h1>400 Bad Request</h1>" CRLF
+"<p>The SSL certificate error</p>" CRLF
;
static char ngx_http_error_496_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>400 No required SSL certificate was sent</title></head>"
CRLF
"<body>" CRLF
-"<center><h1>400 Bad Request</h1></center>" CRLF
-"<center>No required SSL certificate was sent</center>" CRLF
+"<h1>400 Bad Request</h1>" CRLF
+"<p>No required SSL certificate was sent</p>" CRLF
;
static char ngx_http_error_497_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>"
CRLF
"<body>" CRLF
-"<center><h1>400 Bad Request</h1></center>" CRLF
-"<center>The plain HTTP request was sent to HTTPS port</center>" CRLF
+"<h1>400 Bad Request</h1>" CRLF
+"<p>The plain HTTP request was sent to HTTPS port</p>" CRLF
;
static char ngx_http_error_500_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>500 Internal Server Error</title></head>" CRLF
"<body>" CRLF
-"<center><h1>500 Internal Server Error</h1></center>" CRLF
+"<h1>500 Internal Server Error</h1>" CRLF
;
static char ngx_http_error_501_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>501 Not Implemented</title></head>" CRLF
"<body>" CRLF
-"<center><h1>501 Not Implemented</h1></center>" CRLF
+"<h1>501 Not Implemented</h1>" CRLF
;
static char ngx_http_error_502_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>502 Bad Gateway</title></head>" CRLF
"<body>" CRLF
-"<center><h1>502 Bad Gateway</h1></center>" CRLF
+"<h1>502 Bad Gateway</h1>" CRLF
;
static char ngx_http_error_503_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>503 Service Temporarily Unavailable</title></head>" CRLF
"<body>" CRLF
-"<center><h1>503 Service Temporarily Unavailable</h1></center>" CRLF
+"<h1>503 Service Temporarily Unavailable</h1>" CRLF
;
static char ngx_http_error_504_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>504 Gateway Time-out</title></head>" CRLF
"<body>" CRLF
-"<center><h1>504 Gateway Time-out</h1></center>" CRLF
+"<h1>504 Gateway Time-out</h1>" CRLF
;
static char ngx_http_error_505_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>505 HTTP Version Not Supported</title></head>" CRLF
"<body>" CRLF
-"<center><h1>505 HTTP Version Not Supported</h1></center>" CRLF
+"<h1>505 HTTP Version Not Supported</h1>" CRLF
;
static char ngx_http_error_507_page[] =
+"<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>507 Insufficient Storage</title></head>" CRLF
"<body>" CRLF
-"<center><h1>507 Insufficient Storage</h1></center>" CRLF
+"<h1>507 Insufficient Storage</h1>" CRLF
;
--- oldnginx-1.15.6/src/http/modules/ngx_http_autoindex_module.c 2018-11-06 08:32:09.000000000 -0500
+++ nginx-1.15.6/src/http/modules/ngx_http_autoindex_module.c 2018-11-26 22:27:17.434043307 -0500
@@ -446,6 +446,7 @@
ngx_http_autoindex_loc_conf_t *alcf;
static u_char title[] =
+ "<!DOCTYPE html>" CRLF
"<html>" CRLF
"<head><title>Index of "
;
_______________________________________________
nginx-devel mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx-devel