Forked from sielay/gist:0aa4077829f35f5e0310f9e0cc9fdc71
Last active
September 29, 2023 07:17
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
curl https://www.cloudflare.com/ips-v4 > /etc/haproxy/cf-ips
curl https://www.cloudflare.com/ips-v6 >> /etc/haproxy/cf-ips