I try to set a custom HTTP Header with an environment variable** with Apache server 2.4.6 and headers_module.
I work inside a HTTP VHost on port 80.
Everything work as expected with basic example like:
Header set MyHeader "%D %t"
I have read the Apache Documentation of mod_headers : https://httpd.apache.org/docs/2.4/en/mod/mod_headers.html#header
It is said that one can access environment variable using
%{ENVVARNAME}e
(with ENVVARNAME the name of the ENV variable)
I also read other post but no real working answer: Apache set custom header with an evironment variable
But my problem is to add a header than identify my Apache Server like the HOSTNAME environment value
- I tried this
Header Set X-Serv %{HOSTNAME}e
No success : always display X-Serv:{null} instead of the value
- I also tried :
SetEnv myvar ${HOSTNAME}
Header set X-Serv %{myvar}e
No success : it displays in my HTTP Headers : X-Serv: %{myvar}e
I also tried some other various combinations:
Please note: My HOSTNAME environment variable exists and it display in 'env' command with the apache user owning the httpd process
Any idea?