nginx - Iptables string matching to block ips behind Reverse Proxy? -


i have nginx server behind reverse proxy (cloudflare) , want block ips based on xforwarded ip sent in header.

i have tried following iptables string matching rule :

iptables -a input -m string --string "1.1.1.1" --algo bm --to 1024 -j drop

however doesn't seem anything.

why isn't string matching working ? i'm sure real ip sent in packet , either x-forwarded-for or cf-connecting-ip.

kernel 3.4.x , iptables 1.4.7, no issues there .

as mention cf-connecting-ip best way real ip behind cloudflare. better x-forwarded-for can changed if server placed behind load balancer or reverse proxy (x-forwarded-for supports comma separated list in it's rfc).

cloudflare should pass secure traffic , web traffic cloudflare supported web server ports, therefore can whitelist cloudflare ips , enable iptables on other ips. can block ips in firewall tab of cloudflare site in question, looking under ip firewall. non-cloudflare traffic can have iptables applied it.

we use official mod_cloudflare on our apache servers in order correctly ip address our web server , web application itself. on nginx can try ngx_http_realip_module.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -