Skip to content

Instantly share code, notes, and snippets.

@Xvezda
Last active March 17, 2020 15:37
Show Gist options
  • Save Xvezda/3021e9b61ae165e4403c5930094dbd1d to your computer and use it in GitHub Desktop.
Save Xvezda/3021e9b61ae165e4403c5930094dbd1d to your computer and use it in GitHub Desktop.
Generate ngx_http_realip_module configration by curl which restore visitor IP from cloudflare ip range
#!/usr/bin/env bash
curl -s --url https://www.cloudflare.com/ips-v4 \
--url https://www.cloudflare.com/ips-v6 \
| xargs -I{} echo 'set_real_ip_from' {}';' \
| sed '$a\'$'\n''real_ip_header CF-Connecting-IP;'$'\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment