Iptables – Blacklist IPs with iptables behind a Reverse Proxy

iptablesreverse-proxyx-forwarded-for

I have a Ubuntu Server 16 and I use iptables as firewall. HTTP and HTTPS traffic is behind a Reverse Proxy that I cannot control, but I have X-Forwarded-For field activated.

Is it possible to filter out traffic at the iptables stage instead of adding rules in Apache?

If not what is the best way to implement black list in Apache?

Best Answer

iptables is not able to inspect that deeply into packets. Even if it could, it would only be able to inspect HTTP traffic, not HTTPS. In apache, you can blacklist using the Limit directive.