proxy_cache_key with variables

sz_g nginx-forum at nginx.us
Mon Jul 6 13:49:35 UTC 2015


I've just created a configuration composed of two servers.
Both just forwards traffic from different ports (and protocols) to different
servers, and keep responses in cache. It works nice.

For both servers "GET /" request is sent, in the response there is proper
resource. Thus (to distinguish responses in the cache) I added for both
cache_key:

proxy_cache_key "$upstream_addr*$request";

But it doesn't work. I found that upstream states are not available and thus
"proxied" address is not known when cache key is computed. And "proxied"
address is computed only when additional stream must be used..

Is there any way to get proper key? Or any other way to keep all copies in
the cache?

I plan to add "load balancing" module, which would be able to forward
request on (multiple) source addresses to multiple proxied addresses, with
caching.. Will it work properly?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,260086,260086#msg-260086



More information about the nginx mailing list