
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
#!/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
💘 相关文章
- nginx安全设置之-限制IP来源只能为cloudflare
- nginx: [emerg] Solution to unknown directive "set_real_ip_from"
- how to do config nginx allow's cloudflare ip's
- 比较简单实用高效的网站防止灌水和反爬虫方案
- 亲测可用debian 9添加多ip实例的方法
- nginx nginx "--with-ipv6" option is deprecated 问题
- 一款可视化适合小白的cdn构建系统
- Nginx – Unit nginx.service is masked的解决方法
- shell一键查询公网IP地址
- 华为云服务器登录出现“keyboard-interactive authentication prompts from server:”解决方法