nginx 可以自定义 403 页面
error_page 403 /403.html;
也可以deny一些ip的访问,
deny 192.168.1.0/24;
但如果像下面这样写的话会发现自定义的erro 403页面不管用了:
deny 192.168.1.0/24;
error_page 403 /403.html;
location = /403.html {
root html;
}
这是因为deny语句把所有对403.html的访问给deny了,所以需要在locaction = /403.html里面加上allow all,具体过程如下:
deny 192.168.1.0/24;
error_page 403 /403.html;
location = /403.html {
root html;
allow all;
}
# /usr/local/nginx/sbin/nginx -t
# /usr/local/nginx/sbin/nginx -s reload
相关文章
- nginx 虚拟主机 源码解析
- nginx proxy 模块请求发往上游
- nginx if 多重判断
- Git冲突:commit your changes or stash them before you can merge. 解决办法
- Nginx 屏蔽 中国 IP
- NGINX 配置404错误页面转向