Skip to content

vlajos/cloudflare-nginx-config-update

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Cloudflare-Nginx-Config-Update

==============

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

Synopsis

cloudflare-nginx-config-update.sh    [OPTIONS] [target]

Options, Arguments

target is the name of the nginx configration snippet file. Its default value is /etc/nginx/conf.d/cloudflare.conf.

  • -c Using CF-Connecting-IP header instead of the default X-Forwarded-For.
  • -4 Disabling IPv4 IPs.
  • -6 Disabling IPv6 IPs.
  • -x Disabling real_ip_header directive.
  • -r Real run mode: Overwrite the original file.
  • -s Shows the difference between the original file and the newly generated one.
  • -n Disabling backups. (By default he original file is saved with a .bak suffix.)
  • -d Debug mode: shows the core logic's all steps.
  • -q Quiet 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.)
  • -h Help. Displays this page.

Sample usages

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

Dependencies

Author

Veres Lajos

Original source

https://github.com/vlajos/cloudflare-nginx-config-update

Feel free to use!

Releases

No releases published

Packages

No packages published

Languages