git clone https://github.com/openresty/headers-more-nginx-module.git

configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-openssl=../openssl-1.0.2n --with-openssl-opt=enable-tls1_3 --with-ld-opt=-ljemalloc --add-module=../nginx-rtmp-module-master --add-module=../ngx_devel_kit-0.3.0 --add-module=../lua-nginx-module-0.10.12rc1 --add-module=../echo-nginx-module --with-stream --with-stream_ssl_module --add-module=../nginx_cookie_flag_module-master --add-module=../headers-more-nginx-module

# set the Server output header
more_set_headers 'Server: my-server';

# set and clear output headers
location /bar {
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' -s 413 'Foo: Bar';
more_clear_headers 'Content-Type';

# your proxy_pass/memcached_pass/or any other config goes here...
}

# set output headers
location /type {
more_set_headers 'Content-Type: text/plain';
# ...
}

# set input headers
location /foo {
set my_host 'my dog';
more_set_input_headers 'Host:
my_host';
more_set_input_headers -t 'text/plain' 'X-Foo: bah';

# now host andhttp_host have their new values...
# ...
}

# replace input header X-Foo *only* if it already exists
more_set_input_headers -r 'X-Foo: howdy';

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code