Skip to content

Instantly share code, notes, and snippets.

@punkeel
Created August 25, 2013 12:31
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 punkeel/6333631 to your computer and use it in GitHub Desktop.
Save punkeel/6333631 to your computer and use it in GitHub Desktop.
In your nginx.conf, in the http block, add include cf_rules.conf; Then, "touch /etc/nginx/cf_rules.conf" and you're free to use the bash script ! Thanks to CloudFlare's service. :)
#!/bin/bash
echo "real_ip_header CF-Connecting-IP;">/etc/nginx/cf_rules.conf;
for f in $(curl "https://www.cloudflare.com/ips-v4"); do
echo "set_real_ip_from $f;">>/etc/nginx/cf_rules.conf;
done
for f in $(curl "https://www.cloudflare.com/ips-v6"); do
echo "set_real_ip_from $f;">>/etc/nginx/cf_rules.conf;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment