gpt4 book ai didi

带有 ip 白名单的 nginx 维护页面

转载 作者:行者123 更新时间:2023-12-02 01:49:52 28 4
gpt4 key购买 nike

对于我的网站,我希望能够建立一个维护 503 页面,但有一个能够正常使用该网站的 ip 地址白名单

我必须在 lua 中制作这样的东西吗?

我看到一些问题,比如

Nginx Ip Whitelist

How can I setup a custom 503 error page in NGINX?

这解释了如何单独执行此操作,但我想将它们结合起来,这样我就可以使站点对外界脱机,但仍然能够从某些 IP 地址正常测试它

最佳答案

您可以使用 ngx_http_geo_module:

geo $denied {
default 1; # nobody is allowed access by default

# but people from the following networks/ip addresses are allowed access
include whitelist;
127.0.0.1 0;
192.168.1.0/24 0;
}

server {
location / {
if ($denied) {
return 503;
}
}
}

关于带有 ip 白名单的 nginx 维护页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23447535/

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