Regex in proxy_hide_header

Oleg A. Mamontov oleg at mamontov.net
Thu May 3 12:02:06 UTC 2018


On Wed, May 02, 2018 at 01:14:58PM +0000, bmrf wrote:
>Oleg A. Mamontov Wrote:
>-------------------------------------------------------
>> On Wed, May 02, 2018 at 09:34:04AM +0000, bmrf wrote:
>> >Hi list,
>> >
>> >I was trying to unset/delete a header using proxy_hide_header. The
>> problem
>> >is that the header name is always unknown, but it has always the same
>> >pattern, it starts with several whitespaces followed by random
>> characters,
>> >something like \s+\w+
>> >
>> >If regex is not supported at proxy_hide_header, as it seems it is,
>> is there
>> >any other way to accomplish this?
>>
>> Probably it makes sense to take a look:
>> https://github.com/openresty/headers-more-nginx-module#more_clear_head
>> ers
>>
>> "The wildcard character, *, can also be used at the end of the header
>> name to specify a pattern."
>
>The header I need to delete is always different, each time a request is done
>it is different and alway with this weird patter  \s+\w+. (4 whitespaces
>followed by 8 random characters)
>
>Some real examples, it's cut to 1 whitespace character, but there're 4:
>
>"     XkIOPalY"
>"    peYhKOlx"
>"    KpyTKolq"
>
>So using headers-more-nginx-module wildcard character, *, at the end of the
>header name does not help here. Anyway, thank you and if you have any other
>suggestion it's more than welcome.

Okay, so it seems that https://github.com/openresty/lua-nginx-module#header_filter_by_lua_block
using iteration over https://github.com/openresty/lua-nginx-module#ngxrespget_headers
is what you're looking for.

>> >
>> >Thanks a lot!

-- 
Cheers,
Oleg A. Mamontov

mailto: oleg at mamontov.net

skype:  lonerr11
cell:   +7 (903) 798-1352


More information about the nginx mailing list