Module mod_header_modify
For the impatient: Download, install, configure, have fun. RTFM (included) if it doesn't work...
Changing incoming http headers
Summary
This is a small Apache module that will modify, add or remove incoming http headers.
Table Of Contents
Introduction
Configuration Directives
Miscellaneous
Introduction
This module can change or remove incoming http headers and it can also add headers that weren't sent by the client. It can thus be used to manipulate the behaviour of content handlers that you don't want to (or can't) change. Another option might be to simulate various user agents, perhaps in conjuction withmod_rewrite.Download
The module together with the documentation (i.e., this website) is available at http://www.weitz.de/files/mod_header_modify.tar.gz. The current version is 20020604.Requirements
mod_header_modifyhas been tested successfully with Apache 1.3.23 on Linux 2.4.19 but I think it should work with all recent Apache releases and on all supported platforms. Please let me know about your attempts (whether successful or not) with other operating systems or other versions of Apache.You'll need a working C compiler and its associated utilities, of course. If you've built your Apache from a source distribution you almost certainly have one... :)
Installation
There are at least two ways to install this module. Which one is appropriate depends on your Apache installation.The easy way: If your Apache is compiled with support for dynamically loadable modules (also called DSO support), you'll just have to find out where
apxsis located. Go to the directory where you unpacked themod_header_modify.csource file and letapxsdo the work:This will build/usr/local/apache/bin/apxs -c -i -a mod_header_modify.cmod_header_modify.soas a shared object (the-coption), install the module in the right place (-i) and add theLoadModuledirective to yourhttpd.conffile (-a). See theapxsmanual page for details about these and other command line options.If you don't know if you have DSO support, don't worry -
apxswill complain in case you haven't. You can also check beforehand by letting Apache list all compiled-in modules withhttpd -l. Ifmod_so.cis one of them, you're lucky.The hard way: Without DSO support you will have to rebuild Apache to use
mod_header_modify. (You might consider building it with DSO support this time...) Create a new directory like, say,siteunderneath thesrc/modulesdirectory in Apache's source tree and put themod_header_modify.cfile there. Now configure Apache withand don't forget the other configuration options that you need. You can now build and install a new./configure --activate-module=src/modules/site/mod_header_modify.c \ --enable-module=header_modifyhttpdas usual.
Configuration Directives
HeaderModify
Syntax:HeaderModify{on,off}
Default:HeaderModify off
Context: server config, virtual host, directory, location, .htaccess
The
HeaderModifydirective enables or disablesmod_header_modify. If it is set tooffthis module does no runtime processing at all.Use this directive to disable the module instead of commenting out all directives!
HeaderModifyReplace
Syntax:HeaderModifyReplaceHeader Value
Default: None
Context: server config, virtual host, directory, location, .htaccess
The
HeaderModifyReplacedirectives tell the server which headers should be replaced or created. (If the header didn't exists in the original request, it will be created. If it did exist, it will be replaced.)Example:
HeaderModifyReplace Content-type text/xml
HeaderModifyRemove
Syntax:HeaderModifyRemoveHeader
Default: None
Context: server config, virtual host, directory, location, .htaccess
The
HeaderModifyRemovedirectives tell the server which headers should be removed from the request.Example:
HeaderModifyRemove Accept-Encoding
HeaderModifyLog
Syntax:HeaderModifyLog{on,off}
Default:HeaderModifyLog off
Context: server config, virtual host, directory, location, .htaccess
If
HeaderModifyLogis set toon, header modifications will be written to the server log file with a severity level ofwarn.
HeaderModifyInherit
Syntax:HeaderModifyInherit{on,off}
Default:HeaderModifyInherit off
Context: server config, virtual host, directory, location, .htaccess
If this directive is set to
on, the current scope will inherit themod_header_modifysettings from the parent scope by the following rules: All replacement and removal directives will be added to the parent's list of replacements and removals. All other settings will be inherited from the parent if they are not explicitly overwritten in the child's scope.If this directive is set to
off, the parent scope will be completely ignored.
Miscellaneous
Disclaimer
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copyright
Copyright (c) 2002 Dr. Edmund Weitz. All rights reserved.
$Header: /usr/local/cvsrep/weitz.de/mod_header_modify.html,v 1.6 2007/06/04 19:27:03 edi Exp $