I was fiddling with some Apache ACLs for one of my projects that I host on SourceForge. They seem to be using Nginx in from of their Apache farms, so ACLs based on the src IP did not want to work at all. Since all I do all day is reverse proxying (at Y!), it was pretty obvious that the src IP was the IP of the Nginx box, and not the client. So, I modified my rules to check the X-Remote-Addr header instead (hopefully their Nginx is smart enough to set this somewhat safely...). I ended up with an Apache rule like
SetEnvIf X-Remote-Addr 1.2.3.4 is_trusted_ip
SetEnvIf X-Remote-Addr 4.3.2.1 is_trusted_ip
<Files somefile.php>
Order Deny,Allow
Deny from all
Allow from env=is_trusted_ip
</Files>
Yes, I know, I could probably use X-Forwarded-For as well, but then I'd risk having multiple IPs in the header.
Drupal Update
To hack around this problem for my SourceForge site (where all src IPs now show up as at 127.0.0.1), I added the following ugly hack to the beginning of my includes/bootstrap.inc file:
if ($_SERVER['HTTP_X_REMOTE_ADDR']) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REMOTE_ADDR'];
}