Skip to content

Instantly share code, notes, and snippets.

@zveronline
Forked from sielay/gist:0aa4077829f35f5e0310f9e0cc9fdc71
Last active September 29, 2023 07:17
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zveronline/4352ebdf7f9888f16a7edf695fc27ead to your computer and use it in GitHub Desktop.
Save zveronline/4352ebdf7f9888f16a7edf695fc27ead to your computer and use it in GitHub Desktop.
Haproxy - Capture client IP when behind CloudFlare or not. Also keep x-forwarded-for in logs
acl from_cf src -f /etc/haproxy/cf-ips
http-request set-src req.hdr(CF-Connecting-IP) if from_cf
option forwardfor if-none
@zveronline
Copy link
Author

zveronline commented Dec 25, 2017

curl https://www.cloudflare.com/ips-v4 > /etc/haproxy/cf-ips
curl https://www.cloudflare.com/ips-v6 >> /etc/haproxy/cf-ips

@robert1112
Copy link

Thank you for sharing. It solved my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment