==============
Small script to automatically update Cloudflare's public IPs in your nginx configuration. You can schedule it with cron.
Current version is in beta stage!
Roughly it generates a similar output like this: https://support.cloudflare.com/hc/en-us/articles/200170706-How-do-I-restore-original-visitor-IP-with-Nginx- It uses these source urls: https://www.cloudflare.com/ips/
You have to enable this nginx module as well: http://nginx.org/en/docs/http/ngx_http_realip_module.html
cloudflare-nginx-config-update.sh [OPTIONS] [target]
target is the name of the nginx configration snippet file. Its default value is /etc/nginx/conf.d/cloudflare.conf.
-cUsingCF-Connecting-IPheader instead of the defaultX-Forwarded-For.-4Disabling IPv4 IPs.-6Disabling IPv6 IPs.-xDisabling real_ip_header directive.-rReal run mode: Overwrite the original file.-sShows the difference between the original file and the newly generated one.-nDisabling backups. (By default he original file is saved with a.baksuffix.)-dDebug mode: shows the core logic's all steps.-qQuiet mode: suppress most of the output. (Arguments are processed in order of appearance, Previous argument's processing messages won't be suppressed. Move this to the first place if you want to suppress everything.)-hHelp. Displays this page.
By default nothing important will happen
$ cloudflare-nginx-config-update.sh
Showing the potential changes
$ cloudflare-nginx-config-update.sh -s
A standard usage:
$ cloudflare-nginx-config-update.sh -sr
If you have logcheck or anything similar enabled, you may want to suppress the less interesting outputs:
$ cloudflare-nginx-config-update.sh -qr
- Nginx realip module: http://nginx.org/en/docs/http/ngx_http_realip_module.html
- bash
- wget
- cp
- diff (for showing the diff)
Veres Lajos
https://github.com/vlajos/cloudflare-nginx-config-update
Feel free to use!