Changing upstream response headers, before nginx caching decisions

Maxim Dounin mdounin at mdounin.ru
Fri Jun 23 12:09:02 UTC 2017


Hello!

On Fri, Jun 23, 2017 at 02:31:37PM +0300, Gryzli Bugbear wrote:

> I have the following working scheme:
> 
> Client --> Nginx [caching] --> Apache [backend]
> 
> 
> Sometime the backend returns headers, which I want to modify before 
> nginx caching engine decides how to treat them. One such example is when 
> backend returns Vary:  header.
> 
> 
> I want to achieve the following:
> 
> 
> [Apache backend returns Vary: User-Agent, Header2] --> [Nginx Modifies 
> "Vary:" and removes User-Agent] --> [Nginx caching sees only 'Vary: 
> Header2' (without User-Agent)] --> The final result is that Nginx cache 
> wont take 'User-Agent' into vary considerations. (no cache object per UA).
> 
> That's just an example. I would like to do such modification with other 
> headers also (for example Cache-Control).
> 
> Currently I'm already using Nginx Lua integration, but there is no hook 
> point before the caching engine.
> 
> 
> Would be happy for any suggestions about achieving this scenario.

As of now, the only solution would be to use intemediate proxy 
(without caching) to modify headers returned by your backend.

-- 
Maxim Dounin
http://nginx.org/


More information about the nginx mailing list