Forked from badwallass/generate-nginx-cloudflare-allow.sh
Created
February 1, 2023 10:27
-
-
Save ohforest/d0ff062b85a435998aabaed198f74fce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
cf_ips() { | |
echo "# https://www.cloudflare.com/ips" | |
echo "geo \$realip_remote_addr \$cloudflare_ip {" | |
echo "default 0;" | |
for type in v4 v6; do | |
echo "# IP$type" | |
curl -sL "https://www.cloudflare.com/ips-$type/" | sed "s|\$| 1;|g" | |
echo | |
done | |
echo "}" | |
echo "# Generated at $(LC_ALL=C date)" | |
} | |
cf_ips > /path/to/allow-cloudflare.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment