Skip to content

Commit d641a75

Browse files
committed
Add script to regenerate cloudflare.conf as needed
1 parent 0350652 commit d641a75

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cloudflare-regen

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
cf_networks() {
4+
echo "# From $1"
5+
printf 'set_real_ip_from %s;\n' $(curl -sS "$1" | sort)
6+
echo ""
7+
}
8+
9+
cf_conf() {
10+
echo "# CloudFlare"
11+
echo ""
12+
cf_networks https://www.cloudflare.com/ips-v4
13+
cf_networks https://www.cloudflare.com/ips-v6
14+
echo "real_ip_header X-Forwarded-For;"
15+
echo "real_ip_recursive on;"
16+
echo ""
17+
}
18+
19+
# Generate cloudflare.conf from CloudFlare's public network lists
20+
cf_conf >tpl/etc/nginx/cloudflare.conf

0 commit comments

Comments
 (0)