headers-more-nginx-module icon indicating copy to clipboard operation
headers-more-nginx-module copied to clipboard

more_set_input_headers / more_clear_input_headers -t option

Open saravsars opened this issue 12 years ago • 4 comments

I'm trying to clear Accept-Encoding header for html requests alone, but using -t 'text/html' option not clearing the header. Any fix for it ?

saravsars avatar Sep 30 '13 15:09 saravsars

Please note that using -t 'text/html' in more_set_input_headers or more_clear_input_headers means filtering by the Content-Type request header, rather than the response header.

If checking the Content-Type request header is indeed what you want here, then please provide a minimal example that can reproduce your problem :)

agentzh avatar Oct 01 '13 02:10 agentzh

Yes I want to filter request headers. I think we cannot filter the request headers using Content-Type header. I want to filter using Accept header .

Example: If a request comes with header Accept : text/html clear the Accept-Encoding header.

Thanks for the quick response :+1:

saravsars avatar Oct 01 '13 06:10 saravsars

@saravsars The ngx_headers_more module does not support this (yet).

I suggest you use ngx_lua module's rewrite_by_lua or access_by_lua directive to do this for now. For example,

    rewrite_by_lua ' 
        local accept = ngx.var.http_accept
        if accept and string.find(accept, "text/html") then
            ngx.req.clear_header("Accept-Encoding")
        end
    ';

It's very easy and also efficient to do such things in Lua anyway :)

agentzh avatar Oct 01 '13 06:10 agentzh

Yeah I'm currently using ngx_lua module for this. For easy configuration and maintenance I thought of using ngx_headers_more module.

Thanks :+1:

saravsars avatar Oct 01 '13 07:10 saravsars