gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 23:49:54 24 4
gpt4 key购买 nike

每当发生 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;
}

编辑:将 error_page 代码从 504 更正为 403,但我仍然遇到相同的问题

最佳答案

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

似乎我不是唯一遇到此问题的人:

error_page 403 /e403.html;
location = /e403.html {
root html;
allow all;
}

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

看来我对错误页面的访问被阻止的想法是正确的。

关于webserver - 使用 nginx 返回自定义 403 错误页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3119108/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com