Skip to content

Instantly share code, notes, and snippets.

@double-p
Created October 19, 2016 16:43
Show Gist options
  • Save double-p/6b371eb9701dd6481cacbb28f8a973fe to your computer and use it in GitHub Desktop.
Save double-p/6b371eb9701dd6481cacbb28f8a973fe to your computer and use it in GitHub Desktop.
frontend whatever
acl badclient_ips hdr(CF-connecting-IP) -f /etc/haproxy/badclient_ips.lst
acl badclient_ips src -f /etc/haproxy/badclient_ips.lst
http-request deny if badclient_ips
backend from_above
acl new_hdr hdr_reg(CF-connecting-IP) [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*
http-request set-header Proxy-ip %ci if !new_hdr
http-request set-header X-Real-IP %ci if !new_hdr
http-request set-header Proxy-ip %[req.hdr(CF-connecting-IP)] if new_hdr
http-request set-header X-Real-IP %[req.hdr(CF-connecting-IP)] if new_hdr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment