nginx定义error 403页面
nginx定义error 403页面
但如果像下面这样写的话你可能会发现自定义的erro 403页面不管用了
而是显示nginx的默认403提示信息:
deny 192.168.0.1;deny 10.0.0.0/24;error_page 403 /error.html;location = /error.html {root /var/www/error.html;}
这是因为deny语句把所有对403.html的访问都给给deny了,所以需要在locaction = /403.html的语句里面加上allow all,具体过程如下:
vim /etc/nginx/nginx.conf
deny 192.168.0.1;deny 10.0.0.0/24;error_page 403 /error.html;location = /error.html {root /var/www/error.html;allow all;}
nginx -s reload
好了访问下就可以了