Module mod_headers

Important: Information for this topic supports the latest PTF levels for HTTP Server for i5/OS . It is recommended that you install the latest PTFs to upgrade to the latest level of the HTTP Server for i5/OS. Some of the topics documented here are not available prior to this update. See http://www.ibm.com/servers/eserver/iseries/software/http/services/service.htm Link outside Information Center for more information.

Summary

The headers module allows for the customization of HTTP request and response headers. The module allows headers to be merged, replaced or removed.

Directives

RequestHeader

Module: mod_headers
Syntax: RequestHeader action header value
Default: none
Context: server config, virtual host, directory, .htaccess
Override: none
Origin: Apache
Example: RequestHeader set Accept-Encoding "gzip
Example: RequestHeader unset Referer

The RequestHeader directive can replace, merge or remove HTTP request headers. The header is modified just before the content handler is run, allowing incoming headers to be modified. The action it performs is determined by the first argument.

This argument is followed by a header name, which can include the final colon, but it is not required. Case is ignored. For add, append, and set, a value is given as the third argument. If this value contains spaces, it should be surrounded by double quotes. For unset, no value should be given.

Order of Processing

The RequestHeader (and Header) directives can occur almost anywhere within the server configuration. It is valid in the main server config and virtual host sections, inside <Directory>, <Location>, and <Files> sections, and whithin .htaccess files.

The RequestHeader directives are processed in the following order:

  1. main server
  2. virtual host
  3. <Directory> sections and .htaccess
  4. <Location>
  5. <Files>

Order is important. These two headers have a different effect if reversed:

RequestHeader append MirrorID "mirror 12"
RequestHeader unset MirrorID

This way round, the MirrorID header is not set. If reversed, the MirrorID header is set to "mirror 12".

The RequestHeader directive is processed just before the request is run by its handler in the fixup phase. This should allow headers generated by the browser, or by Apache input filters to be overridden or modified. For example,

RequestHeader append MirrorID "mirror 12"
Parameter One: action
  • The action parameter can be one of the following values:
    Action Description
    set The request header is set, replacing any previous header with this name.
    append The request header is appended to any existing header of the same name. When a new value is merged into an existing header, it is separated from the existing header with a comma. This is the HTTP standard way of giving a header multiple values.
    add The request header is added to the existing set of headers, even if this header already exists. This can result in two (or more) headers having the same name. This can lead to unforeseen consequences, and in general append should be used instead.
    unset The request header of this name is removed, if it exists. If there are multiple headers of the same name, all will be removed.
Parameter Two: header
  • The HTTP Response header parameter to be set, appended, or unset with this directive. There is no validity checking of the header, which allows the use of experimental headers.
Parameter Three: value
  • The value parameter can have any valid character string as a value and specifies the value of the header to be set. It is only valid for set, add and append. There is no validity checking of the value specified, which allows the use of experimental headers values. All characters and escaped characters are allowed in this string. If this value contains spaces, it should be surrounded by double quotes.