Reputation: 8815
from http://httpd.apache.org/docs/current/mod/mod_headers.html
"Conditionally send MyHeader on the response if and only if header MyRequestHeader is present on the request. This is useful for constructing headers in response to some client stimulus. Note that this example requires the services of the mod_setenvif module."
SetEnvIf MyRequestHeader myvalue ENV_SET
Header set MyHeader "%D %t mytext" env=ENV_SET
but then from Apache SetEnvIf trouble and from my testing trying to set an environment var by checking the Authorization header, the ENV_SET won't be set at all
SetEnvIf only sets the env variable ENV_SET for the following * Remote_Host * Remote_Addr * Server_Addr * Request_Method * Request_Protocol * Request_URI
Is the documentation wrong or am I misunderstanding something ?
Using: Apache/2.2.15 (Win32) mod_fastcgi/2.4.6 mod_jk/1.2.30
Upvotes: 5
Views: 7779
Reputation: 41
Format is:
SetEnvIf <headername> <regex> <environment variable name and optionally a value>
This worked for me:
SetEnvIf ACTUAL_CLIENT_IP "^172\.111\.0\.27" dontlog
where ACTUAL_CLIENT_IP
is the name of the HTTP header which stores the actual client IP (as opposed to the Remote_Addr field which gets overwritten with our proxy server's IP).
Upvotes: 4