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
  • Select an option

  • Save zveronline/4352ebdf7f9888f16a7edf695fc27ead to your computer and use it in GitHub Desktop.

Select an option

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

zveronline commented Dec 25, 2017

Copy link
Copy Markdown
Author

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
Copy Markdown

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