Skip to content

Instantly share code, notes, and snippets.

@badwallass
Created July 12, 2022 12:53
Show Gist options
  • Save badwallass/f7f8ba1e22b8987cf8d790f4f00b2db7 to your computer and use it in GitHub Desktop.
Save badwallass/f7f8ba1e22b8987cf8d790f4f00b2db7 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