How can use X-Forwarded-For headers(my proxy ip 10.1.1.x) to allow HTTP query?
3 Answers
You can use SetEnvIf and Allow:
<Location "/only_proxy/">
SetEnvIf X-Forwarded-For ^10\.1\.1\. proxy_env
Order allow,deny
Satisfy Any
Allow from env=proxy_env
</Location>
-
1
-
It's also reasonably easy to protect yourself from forged X-Forwarded-For headers (by stripping this header at entry points into your environment).– larsksOct 2, 2012 at 1:52
-
1found this post while looking for information on how to protect against forged x-forwarded headers, would you mind pointing to a relevant doc?– PeteNov 1, 2012 at 17:12
You can write a rewrite rule to redirect to 403 response.
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-For} !(1.1.1.1|2.2.2.2)
RewriteRule .* - [F]
You can use mod_rpaf to make Apache treat the X-Forwarded-For IP as the client IP.
-
8For those who find their way here from Google: note that
mod_rpaf
is only able to make your logs useful; it does not actually affect the address used in access control decisions. Also note that in Apache 2.4, themod_rpaf
functionality is provided natively by mod_remoteip.– larsksOct 2, 2012 at 1:50 -
1