Last active
August 18, 2023 12:11
-
-
Save thecancerus/869184bc67ed9a5d8fde52f93f6f66e1 to your computer and use it in GitHub Desktop.
bash script to create a conf file for using cloudflare proxy ip with nginx based on https://serverfault.com/questions/754481/nginx-geoip-behind-cloudflare-proxy-showing-wrong-country-not-of-end-user-but and https://danielmiessler.com/p/getting-real-ip-addresses-using-cloudflare-nginx-and-varnish
This file contains hidden or 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/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