<!-- review: finished -->

<a id="external-headers-more"></a>

# Headers-More

headers-more 模块允许您添加、设置或删除任何传出或传入的头。

<a id="installation-12"></a>

## 安装

要 [安装](https://cn.angie.software//angie/docs/installation/index.md#install-packages) 该模块,请使用以下软件包之一:

- Angie:`angie-module-headers-more`
- Angie PRO:`angie-pro-module-headers-more`

<a id="loading-the-module-12"></a>

## 加载模块

要使用该模块,必须在 `main{}` 上下文中加载它:

```nginx
load_module modules/ngx_http_headers_more_filter_module.so;
```

在下面的配置示例中,除了该模块自己的指令外,还使用了 echo 模块的指令。
加载 echo 模块:

```nginx
load_module modules/ngx_http_echo_module.so;
```

<a id="configuration-example-88"></a>

## 配置示例

```nginx
http {
    server {
        listen 80;

        root  /usr/share/angie/html;
        index index.html index.htm;

        location /clear {
            more_clear_headers 'Content-Type';
            proxy_pass http://127.0.0.1:8081;
        }

        location /settype {
            more_set_headers 'Content-Type: text/plain';
            proxy_pass http://127.0.0.1:8081;
        }

        location /changetype {
            more_set_headers -t 'text/plain text/css' 'Content-Type: text/newtype';
            proxy_pass http://127.0.0.1:8081;
        }

        location /newheader {
            more_set_headers -t 'text/plain text/css' 'New-Header: foo';
            proxy_pass http://127.0.0.1:8081;
        }

        location /404 {
            more_set_headers -s '400 404 500 503' 'Upstream-Status: $upstream_status';
            proxy_pass http://127.0.0.1:8081;
        }

        location /input {
            set $my_host 'my.host';
            more_set_input_headers 'Host: $my_host';
            more_set_input_headers -t 'text/plain' 'X-Foo: bar';

            echo "Host: $host";
            echo "X-foo: $http_x_foo";
        }
    }

    server {
        listen 8081;
        default_type text/css;

        location / {
            return 200 "OK\n";
        }

        location /404 {
            return 404 "Done\n";
        }
    }
}
```

<a id="additional-information-13"></a>

## 其他信息

详细文档和源代码可在以下位置获取:
[https://github.com/openresty/headers-more-nginx-module/](https://github.com/openresty/headers-more-nginx-module/)
