Last Updated: February 25, 2016
·
640
· xalakox

Restricting access via .htaccess on Balanced Servers

The Need.. test servers need to access the staging server with no user/pass requirement..

The Problem, Servers are behind a balancer that masks the originating IP address; can't use the classic "Allow from 127.0.0.1" in .htaccess

Solution: use a variable, however we have to go grep way to match the IP address.

SetEnvIf X-Forwarded-For "^127\.0\.0\.1$" AllowAccess
Allow from env=AllowAccess
Satisfy any

You can use this service to get the right grep for IP address ranges