Forum: NGINX Is there any way to access upstream response from configuration?

2974d09ac2541e892966b762aad84943?d=identicon&s=25 aldem (Guest)
on 2014-05-25 20:19
(Received via mailing list)
Hi,

I am trying to make caching selective based on cookies set by upstream.

Example: worpress sets wordpress_test_cookie for every page, thus
preventing
caching of pages unless Set-Cookie headers are ignored. On the other
hand,
ignoring Set-Cookie in general is bad idea, as in this case when other
cookies are set (like wordpress_logged_in) the response will be cached
as
well - and this is a security (and consistency) disaster.

What I want is to check if specific header or cookie in the *response*
is
set and make decision to cache or not based on this information.

Is this possible at all? I couldn't find anything (like variables) that
allows to examine response for this purpose.

PS: I know that there are some "helper" plugins for wordpress, but
wordpress
is only one of possible applications, I need a solution that could work
without application support, that is why I am interested in response
examination.

Thank you!

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,250345,250345#msg-250345
36a8284995fa0fb82e6aa2bede32adac?d=identicon&s=25 Francis Daly (Guest)
on 2014-05-25 21:06
(Received via mailing list)
On Sun, May 25, 2014 at 02:19:16PM -0400, aldem wrote:

Hi there,

> I am trying to make caching selective based on cookies set by upstream.

http://nginx.org/r/proxy_no_cache

> Is this possible at all? I couldn't find anything (like variables) that
> allows to examine response for this purpose.

http://nginx.org/en/docs/http/ngx_http_upstream_mo...

If you specifically care about cookies, it will likely be easier if
you use 1.7.1 or newer. If you merely care about response headers,
then older versions will work too.

You may find it useful to use "map" too.

  f
--
Francis Daly        francis@daoine.org
2974d09ac2541e892966b762aad84943?d=identicon&s=25 aldem (Guest)
on 2014-05-25 22:43
(Received via mailing list)
Francis, I know about no_cache and bypass - question is how to extract
*specific* cookie from the *response* (upstream reply), not the
*request*.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,250345,250347#msg-250347
36a8284995fa0fb82e6aa2bede32adac?d=identicon&s=25 Francis Daly (Guest)
on 2014-05-25 23:44
(Received via mailing list)
On Sun, May 25, 2014 at 04:43:10PM -0400, aldem wrote:
> Francis, I know about no_cache and bypass - question is how to extract
> *specific* cookie from the *response* (upstream reply), not the *request*.

no_cache - yes.
bypass - no.

upstream reply - which part of

"""
$upstream_cookie_name
 cookie with the specified name sent by the upstream server in the
“Set-Cookie” response header field
"""

is unclear or confusing?

  f
--
Francis Daly        francis@daoine.org
2974d09ac2541e892966b762aad84943?d=identicon&s=25 aldem (Guest)
on 2014-05-26 00:17
(Received via mailing list)
Oh... thank you very much, Francis - I don't undestand how could I
overlook
this, please don't hit me hard :)

Though it is introduced only in 1.7.1, but $upstream_http_* is indeed
there
for older versions - perhaps, I am too tired so I missed it...

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,250345,250349#msg-250349
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.