Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to set up access for a directory using .htaccess rules. Apparently, the remote IP is always localhost due to the way the provider ( SourceForge.net ) has set things up.

I've noticed that the correct IP is set in the X-Forwarded-For header.

How can I allow access only to some known hosts based on the X-Forwarded-For header?

share|improve this question

1 Answer 1

RewriteEngine On
SetEnvIfNoCase X-Forwarded-For .+ forwarded=yes
RewriteCond %{ENV:forwarded} yes
RewriteRule ... my conditions ...

X-Forwarded-For can contain more then one ip address if it was forwarded my multiple servers - if that is the case then you need some script to loop trough this list and processes it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.