Skip to content

Instantly share code, notes, and snippets.

@LaurenceJJones
Created November 11, 2022 22:44
Show Gist options
  • Save LaurenceJJones/7e7e386bb1f0dae7054c95df2722a4bb to your computer and use it in GitHub Desktop.
Save LaurenceJJones/7e7e386bb1f0dae7054c95df2722a4bb to your computer and use it in GitHub Desktop.
TARGET_FILE=/etc/nginx/conf.d/cloudflare.conf
REAL_HEADER=CF-Connecting-IP
echo "# AUTOGENERATED FILE" > $TARGET_FILE
for i in `curl -s https://www.cloudflare.com/ips-v4`;
do
echo "set_real_ip_from $i;" >> $TARGET_FILE
done
for i in `curl -s https://www.cloudflare.com/ips-v6`;
do
echo "set_real_ip_from $i;" >> $TARGET_FILE
done
echo "real_ip_header $REAL_HEADER;" >> $TARGET_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment