proxy_cache_key + redirects

Mirosław Jaworski mjaw at ikp.pl
Wed Mar 3 22:26:20 MSK 2010


On Wed, 2010-03-03 at 19:49 +0100, Taras Girnyk wrote:
> Of course, with such setup when i load a.com and after 5 min load b.com
> i see cached result from a.com. But with this login page i can't even
> imagine why this to different urls is caching as the same one.

Unfortunately nginx site lacks sane examples.

If you happen to have Host: header based virtual servers on the same
backend and you don't use separate nginx server {} sections for those
virtuals on the frontend, you want to use $host variable within
proxy_cache_key.

I use
proxy_cache_key        $scheme://$host$request_uri;

> Also, if i add $host in proxy_cache_key i'm starting to get permanent
> redirects.

This may be the side effect of the application on the backend, 
which behaves this way when it cannot set cookies ( doesn't receive
it after trying to set it ). Use 
proxy_pass_header  Set-Cookie;
within your proxying location / {}

-- 
Miroslaw "Psyborg" Jaworski
GCS/IT d- s+:+ a C++$ UBI++++$ P+++$ L- E--- W++(+++)$ N++ o+ K- w-- O-
M- V- PS+ PE++ Y+ PGP t 5? X+ R++ !tv b++(+++) DI++ D+ G e* h++ r+++ y?




More information about the nginx mailing list