Modifying Headers by Analyzing Body

abmackenzie nginx-forum at
Tue Feb 5 12:29:19 UTC 2019

Hi all,

I am attempting to develop an NGINX module which is required to modify the
response headers based on the content of the response body, whether from an
upstream proxy or being fulfilled by the server itself.

My current approach, a body filter, does not seem fruitful. By the time the
body filter is invoked the headers have already been sent. There is no way
to generate the correct header without the response body. I cannot find any
mechanism in the NGX API to postpone sending of the headers or access the
response body in a header filter.

I was hoping somebody could either point me in the direction of a solution
(or confirm that what I am trying to do is impossible without modification
of the NGINX source).



Posted at Nginx Forum:,282914,282914#msg-282914

More information about the nginx mailing list