配置nginx的403错误页面跳转

在nginx.conf同目录下创建blockips.conf,加入需要阻止的ip(deny 192.168.1.3)
在nginx中
http
        {
。。。。。。。。         
                include blockips.conf;
        }
导入阻止ip
建立403 error页面

Error 403 - IP Address Blocked

Your IP Address is blocked. If you this an error, please contact webmaster with your IP at 拉瓦锡@qq.com


在nginx中加入
server
        {
                listen       80;
                server_name 192.168.1.3;

                error_page 403 /test403.html;
                location = /test403.html {
                  root /home/www/test;
                  charset utf-8;
              }
重启nginx:   /usr/local/nginx/sbin/nginx -s reload

结果只出现nginx默认的403页面,自定义的403页面不显示


                error_page 403 /test403.html;
                location = /test403.html {
                  root /home/www/test;
                  charset utf-8;
              allow all;
              }
火狐下面可以显示自定义403页面,可IE下死活出不来!
经过一番排查,发现html页面有问题,需要加上:

之后,IE下面就可以显示自定义403页面了

你可能感兴趣的:(为了忘却)