Skip to content

Instantly share code, notes, and snippets.

@rojenzaman
Last active July 20, 2023 23:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rojenzaman/7c4e7120de6f8b9993a8495fd386522d to your computer and use it in GitHub Desktop.
Save rojenzaman/7c4e7120de6f8b9993a8495fd386522d to your computer and use it in GitHub Desktop.
Script to set real IP from cloudflare for NGINX
#!/bin/bash
ips_v4=$(curl -s https://www.cloudflare.com/ips-v4)
ips_v6=$(curl -s https://www.cloudflare.com/ips-v6)
while IFS= read -r line; do
echo "set_real_ip_from $line;"
done <<< "$ips_v4"
while IFS= read -r line; do
echo "set_real_ip_from $line;"
done <<< "$ips_v6"
echo "real_ip_header CF-Connecting-IP;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment