Configure nginx to only allow cloudflare's IP to connect to the server shell script
Configure nginx to only allow cloudflare's IP to connect to the server shell script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
set -e
cf_ips() {
echo "# https://www.cloudflare.com/ips"
for type in v4 v6; do
echo "# IP$type"
curl -sL "https://www.cloudflare.com/ips-$type/" | sed "s|^|allow |g" | sed "s|\$|;|g"
echo
done
echo "# Generated at $(LC_ALL=C date)"
}
#cf_ips > /usr/local/nginx/conf/cf.conf
(cf_ips && echo "deny all; # deny all remaining ips") > /etc/nginx/conf/cf.conf
nginx -s reload or service lsws restart
chmod +x cf.sh ./cf.sh
💘 相关文章
- how to do config nginx allow's cloudflare ip's
- nginx: [emerg] Solution to unknown directive "set_real_ip_from"
- nginx安全设置之-限制IP来源只能为cloudflare
- 写入指定IP数据到指定文件到简单shell脚本
- 快速构建高可用的IP,科学上网方法
- 免费的Nginx 代理,管理器面板
- nginx "ssl_stapling" ignored, issuer certificate not found for certificate解决方法
- FreeBSD 安装PHP7.4 和 Nginx
- 查看當前使用的shell的多種方法
- MySQL8 method to restrict the connection of the intranet IP segment