加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

webserver – 使用nginx返回自定义403错误页面

发布时间:2020-12-13 21:00:26 所属栏目:Nginx 来源:网络整理
导读:我试图在发生403错误时在/temp/www/error403.html中显示错误页面. 这应该是每当用户尝试通过https(ssl)访问该站点并且它的IP位于blovkips.conf文件中时,但此时它仍然显示nginx的默认错误页面. 我有其他服务器相同的代码(没有任何阻止),它的工作原理. 是否阻

我试图在发生403错误时在/temp/www/error403.html中显示错误页面.

这应该是每当用户尝试通过https(ssl)访问该站点并且它的IP位于blovkips.conf文件中时,但此时它仍然显示nginx的默认错误页面.
我有其他服务器相同的代码(没有任何阻止),它的工作原理.

是否阻止IP访问自定义403页面?
如果是这样,我如何让它工作?

server  {
    # ssl
    listen               443;
    ssl                  on;
    ssl_certificate      /etc/nginx/ssl/site.in.crt;
    ssl_certificate_key  /etc/nginx/ssl/site.in.key;
    keepalive_timeout    70;

    server_name localhost;


    location / {
            root   /temp/www;
            index  index.html index.htm;
}

# redirect server error pages to the static page
error_page   403  /error403.html;
# location = /error403.html {
#         root   /temp/www;
# }

    # add trailing slash if missing
    if (-f $document_root/$host$uri) {
            rewrite ^(.*[^/])$$1/ permanent;
    }      

    # list of IPs to block
    include blockips.conf;
}

编辑:
修正了错误页面代码从504到403,但我仍然遇到同样的问题

最佳答案
我在来到这里之前做了很多谷歌搜索,但刚刚做了一些,在5分钟内得到了答案:P

似乎我不是唯一有这个问题的人:

http://www.cyberciti.biz/faq/unix-linux-nginx-custom-error-403-page-configuration/

似乎我认为对我的错误页面的访问被阻止是正确的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读