How to use environment variable from mod_rewrite to interpolate proxypass in httpd.conf

I am using apache 2.4 and trying to use the environment variable inside the conf file for proxy pass. There is a thread [ Apache proxypass using the URL of the variable with interpolation ], saying this:

RewriteEngine on
RewriteMap lowercase int:tolower

#This sets the variable to env:
RewriteRule ^ - [E=SERVER_NAME:${lowercase:%{SERVER_NAME}}]

#Now interpolate makes variables available for proxypass & proxypassreverse:
ProxyPassInterpolateEnv On
ProxyPass / ajp://${SERVER_NAME}:8009/ interpolate
ProxyPassReverse / ajp://${SERVER_NAME}:8009/ interpolate

But when I tried this myself, I get the error "AH00111: Config variable $ {SERVER_NAME} not defined". This means that Apache2.4 considers the variable $ {SERVER_NAME} as a configuration variable, not an environment variable.

I also tried using mod_rewrite sytax for a variable like this,

ProxyPass / ajp://%{ENV:SERVER_NAME}:8009/ interpolate
ProxyPassReverse / ajp://%{ENV:SERVER_NAME}:8009/ interpolate

But% {ENV: SERVER_NAME} was treated as a plaintext string and generated an error, since this is not a valid URL.

"" . , SERVER_NAME mod_rewrite. mod_rewrite [P], ProxyPassReverse, . mod_rewrite ProxyPassReverse.

, confipass confyp?

+4
1

, Apache , , :

ProxyPassReverse / ajp://${SERVER_NAME}:8009/ interpolate

. , ProxyPass .. , , , Apache 2.4.10, mod_proxy code ${varname}, httpd.conf.

, , Apache .

, Apache , , .

+2

All Articles