Forum Moderators: phranque
If I look in phpinfo() the variable _SERVER["HTTP_X_CLUSTER_CLIENT_IP"] is the IP address of the user, whereas _SERVER["REMOTE_ADDR"] is the local IP address of the server. I guess that . htaccess is only using SERVER["REMOTE_ADDR"]. Is there a way to block an IP address on cluster system?
SetEnvIf HTTP_X_CLUSTER_CLIENT_IP 192.168.0.1 block
...
SetEnvIf HTTP_X_CLUSTER_CLIENT_IP 10.0.10.100 block
Deny from env=block
An alternative would be to configure the front-end server (reverse proxy configuration) to send the standard HTTP_X_FORWARDED_FOR header to the back-end machine, and then test that header in the back-end code.
Finally, if neither of these mod_access solutions work, you could use mod_rewrite, which allows testing of any arbitrary HTTP header using RewriteCond %{HTTP:Any_Header_Here}
The problem with the mod_rewrite solution is that it is a bit harder to maintain -- It just doesn't "read" as clearly, and you must remember to put an [OR] flag on every RewriteCond but the last one...
Also, since you're talking about a fairly sophisticated front-end/back-end system here, can you block IP addresses at a firewall -- either a hardware firewall or via front-end machine software?
A hardware firewall is the best choice, followed by a software firewall on the front-end, and finally a firewall or httpd/.htaccess code on the back-end. But the sooner you can reject the requests, the smaller your exploit exposure will be, and the cleaner your log files will be.
Jim
RewriteCond %{[b]HTTP:[/b]HTTP_X_Cluster_Client_IP} ^10\.0\.10\.100$
Jim