Invalid command ‘Header’, perhaps misspelled or defined by a module not included in the server configuration

Tuesday, February 3, 2009

I was trying to enable gzip compression in apache with the help from the link http://httpd.apache.org/docs/2.0/mod/mod_deflate.html.

The apache I had was compiled from source. So I had to recompile Apache with the extra configuration parameter "--enable-deflate".

After modifying the httpd.conf as mentioned in the above link, I restarted Apache and got this error - "Invalid command ‘Header’, perhaps misspelled or defined by a module not included in the server configuration". When I commented the line "Header append Vary User-Agent env=!dont-vary" and restarted Apache, it worked. The gzip compression in Apache worked fine.

But I wanted to enable "Header append Vary User-Agent env=!dont-vary" because that would make sure that proxies don't deliver the wrong content.

The error message "Invalid command 'Header'" appeared because the Apache module mod_headers was not enabled. To enable mod_headers, I had to recompile Apache with the configuration parameter "--enable-headers".

If you installed Apache from a build, then you will have to add the line
LoadModule headers_module modules/mod_headers.so
in httpd.conf.

The list of configuration parameters can be seen at http://httpd.apache.org/docs/2.0/programs/configure.html.

0 comments: