On Mon, Oct 07, 2019 at 12:07:29PM -0700, Roger Fischer wrote:

Hi there,

> is there a way in an NGINX HTTP Proxy to add a header to the response before 
> it is cached?
> 
> I would like to capture some information from the request and add it to the 
> cached response, so that all clients getting the cached response receive that 
> info.

If you do not find a more direct way (either by config or by coding),
then you could potentially add a new nginx server{} to modify the upstream
response as you want.

That is:

* main nginx does proxy_pass to new nginx, including your extra
information as proxy_set_header values. main nginx does proxy_cache
the response.

* new nginx does proxy_pass to upstream; does not proxy_cache the response;
and does add_header with your extra information so that that extra
information is in the response that goes to main nginx.

"new nginx" can be a server{} that listens on a loopback port, or on a
unix domain socket -- something that the world does not need to access
directly.

        f
-- 
Francis Daly        [email protected]
_______________________________________________
nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

Reply via email to