Skip to content

Instantly share code, notes, and snippets.

@thecancerus
Last active August 18, 2023 12:11
Show Gist options
  • Save thecancerus/869184bc67ed9a5d8fde52f93f6f66e1 to your computer and use it in GitHub Desktop.
Save thecancerus/869184bc67ed9a5d8fde52f93f6f66e1 to your computer and use it in GitHub Desktop.
#!/bin/sh
# /etc/nginx/geoip_update.sh
# Update GeoIP proxy list to the current list of cloudflare IP addresses
outfile=$(dirname "$0")/cloudflare_proxy_ips.conf
echo "# Auto-generated by $0" > "$outfile"
(
curl https://www.cloudflare.com/ips-v4
) | while read ip; do
echo "set_real_ip_from $ip;"
done >> "$outfile"
(
curl https://www.cloudflare.com/ips-v6
) | while read ip; do
echo "set_real_ip_from $ip;"
done >> "$outfile"
echo "real_ip_header CF-Connecting-IP;" >> "$outfile"
echo List updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment