Search code examples
apachemod-proxy

How can I reference environment variable in http.conf of Apache under mod_proxy settings


How can I reference environment variable in http.conf of Apache under mod_proxy settings? I set targetserver as environment variable but apache mod_proxy couldn’t resolve. Any thoughts?

Configuration:
ProxyPass /lac/ http://${targetserver}/ 

Error message received from server

The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /lac/.
Reason:
DNS lookup failure for: ${targetserver}
Apache/2.2.15 (CentOS) Server at localhost Port 80

Solution

  • I used Apache/2.4.12 and I am able access environment variable using ${ENV_VARIABLE_NAME} for example: ${targetservername}

    Server version: Apache/2.4.12 (Unix)

    Server built: Apr 28 2015 10:58:48