Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Set, add, and clear arbitrary output headers
Perl C Shell

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


This module allows you to add, set, or clear any output
or input header that you specify.

This is an enhanced version of the standard
"headers" module because it provides more utilities like
resetting or clearing "builtin headers" like "Content-Type",
"Content-Length", and "Server".

It also allows you to specify an optional HTTP status code
criteria using the -s option and an optional content
type criteria using the -t option while modifying the
output headers. For example,

    more_set_headers -s 404 -t 'text/html' 'X-Foo: Bar';

Input headers can be modified as well. For example

    location /foo {
        more_set_input_headers 'Host: foo' 'User-Agent: faked';
        # now $host, $http_host, $user_agent, and
        #   $http_user_agent all have their new values.

The option -t is also available in the
"more_set_input_headers" directive while the -s option
is not allowed.

Variables are allowed in your new input/output headers'
values, for instance,

    set $my_server 'Super Star Server';
    more_set_headers 'Server: $my_server';

But variables won't work in header keys due to performance

Multiple set/clear header directives are allowed in a
single location, and they're executed sequentially.

Directives inherited from an upper level scope (say,
"http" block or "server" blocks) are executed before
the directives in the "location" block.


    more_set_headers 'Server: my-server';

    location /foo {
        more_set_headers 'X-MyHeader: blah' 'X-MyHeader2: foo';
        more_set_headers -t 'text/plain text/css' 'Content-Type: text/foo';
        more_set_headers -s '400 404 500 503' 'Foo: Bar';
        more_clear_headers 'Transfer-Encoding' 'Content-Type';

    location /type {
        more_set_headers 'Content-Type: text/plain';


Grab the nginx source code from, for example, the
version 0.8.24 (see Nginx Compatibility), and then build the
source with this module:

    $ wget ''
    $ tar -xzvf nginx-0.8.24.tar.gz
    $ cd nginx-0.8.24/

    # Here we assume you would install you nginx under /opt/nginx/.
    $ ./configure --prefix=/opt/nginx \

    $ make -j2
    $ make install

Nginx Compatibility

     0.8.x (last tested version is 0.8.27)
     0.7.x >= 0.7.44 (last tested version is 0.7.64)

Something went wrong with that request. Please try again.