Last active
July 20, 2023 23:10
-
-
Save rojenzaman/7c4e7120de6f8b9993a8495fd386522d to your computer and use it in GitHub Desktop.
Script to set real IP from cloudflare for NGINX
This file contains 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/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