01 修改报错代码
# 修改报错代码
图1 网页错误代码
[root@Nginx-01 conf.d]# cat index.conf
limit_conn_zone $remote_addr zone=conn_zone:10m;
limit_req_zone $binary_remote_addr zone=req_zone:10m rate=1r/s;
server{listen 172.2.25.10:80;root /code/index;server_name www.like.index.com;charset utf-8,gbk;limit_conn conn_zone 1;limit_req zone=req_zone burst=3 nodelay;limit_req_status 478; # 修改报错代码为478location / {autoindex on;autoindex_localtime on;autoindex_exact_size off;limit_rate_after 100m;limit_rate 50k;auth_basic "test";auth_basic_user_file "/etc/nginx/conf.d/passwd";}location /nginx_status {stub_status;allow 172.2.25.1;deny all;}
}
图2 修改错误代码为478
02 修改报错页面
[root@Nginx-01 conf.d]# cat index.conf
limit_conn_zone $remote_addr zone=conn_zone:10m;
limit_req_zone $binary_remote_addr zone=req_zone:10m rate=1r/s;
server{listen 172.2.25.10:80;root /code/index;server_name www.like.index.com;charset utf-8,gbk;limit_conn conn_zone 1;limit_req zone=req_zone burst=3 nodelay;# limit_req_status 478;location / {autoindex on;autoindex_localtime on;autoindex_exact_size off;limit_rate_after 100m;limit_rate 50k;auth_basic "test";auth_basic_user_file "/etc/nginx/conf.d/passwd";error_page 478 503 404 err.html; # 报错页面的路径为/code/index/err.html,因为ROOT为/code/index}location /nginx_status {stub_status;allow 172.2.25.1;deny all;}
}
[root@Nginx-01 conf.d]# cat /code/index/err.html
ERR!!!!!
图3 自定义错误界面