修改源码文件:src/http/ngx_http_special_response.c

在需要修改的错误代码修改例如

static char ngx_http_error_400_page[] =
"<html>" CRLF
"<head><title>400 Bad Request</title>" CRLF
"<style type='text/css'>html, body{overflow:hidden;margin:0;background:#000;}h1{font-family:'Montserrat', 'Helvetica Neue', Arial, sans-serif;font-size:30px;letter-spacing:9px;text-transform:uppercase;color:#eee;margin:12px 0;left:4px;position:relative;position:absolute;top:50%;left:50%;text-align:center;-webkit-transform: translate(-50%, -50%);-moz-transform: translate(-50%, -50%);-ms-transform: translate(-50%, -50%);-o-transform: translate(-50%, -50%);transform: translate(-50%, -50%);}" CRLF
"</style></head><body><h1>400 Bad Request</h1></body></html>" CRLF
;

注:

CRLF 为换行符

; 结尾不要丢分号

顺便把版本信息显示和一条白线删掉

static u_char ngx_http_error_full_tail[] =
"" CRLF
;
static u_char ngx_http_error_build_tail[] =
"" CRLF
;
static u_char ngx_http_error_tail[] =
"" CRLF
;

效果如图

Q.E.D.