0

I am trying to troubleshoot my apache test site right now. I need to have the mod_rewrite variables returned in the header so that I can see what is going on. However, when I try to set them in the header, I get null

Server version: Apache/2.4.51 (Fedora)

config

<VirtualHost mysite.local:80>
  ServerName mysite
  DocumentRoot /var/www/html/mysite
  Header always set TestHeader "%{SERVER_NAME}e"

output from curl

curl -I http://mysite.local/index.html

HTTP/1.1 200 OK
Date: Tue, 01 Feb 2022 02:05:42 GMT
Server: Apache/2.4.51 (Fedora)
TestHeader: (null)
Last-Modified: Tue, 25 Jan 2022 19:37:28 GMT
ETag: "15-5d66d372009de"
Accept-Ranges: bytes
Content-Length: 21
Content-Type: text/html; charset=UTF-8

Also, mod_headers and mod_rewrite are enabled

$ grep -R 'mod_rewrite' conf.modules.d/
conf.modules.d/00-base.conf:LoadModule rewrite_module modules/mod_rewrite.so
$ grep -R 'mod_headers' conf.modules.d/
conf.modules.d/00-base.conf:LoadModule headers_module modules/mod_headers.so

Am I missing some setting or configuration?

Example person
  • 3,198
  • 3
  • 18
  • 45

1 Answers1

0

Try adding PassEnv SERVER_NAME before the Header set.

See PassEnv - mod_env - Apache HTTP Server Version 2.4 Documentation for more info

Example person
  • 3,198
  • 3
  • 18
  • 45