Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ohforest/d0ff062b85a435998aabaed198f74fce to your computer and use it in GitHub Desktop.
Save ohforest/d0ff062b85a435998aabaed198f74fce to your computer and use it in GitHub Desktop.
#!/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