nginx下可以自己定义error 403页面,也可以deny一些ip的访问, 但如果像下面这样写的话你可能会发现自定义的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,具体过程如下: #sudo 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; } #sudo /etc/init.d/nginx restart 好了访问下就可以了
|