headers-more-nginx-module
headers-more-nginx-module copied to clipboard
more_set_input_headers / more_clear_input_headers -t option
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 ?
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 :)
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 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 :)
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: