Skip to content
Set, add, and clear arbitrary output headers
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 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. For example,

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

Variables are allowed in your new headers' values, for

    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.21 (last tested version is 0.7.64)

Something went wrong with that request. Please try again.