Bad default for proxy_cache_key
Maxim Dounin
mdounin at mdounin.ru
Mon Jun 30 23:48:36 UTC 2014
Hello!
On Sun, Jun 29, 2014 at 06:15:56PM -0300, Bráulio Bhavamitra wrote:
> Hello all,
>
> I stucked a while with a config problem where proxy_cache_key default value
> was $scheme$proxy_host$uri$is_args$args".
>
> Then I realized it really didn't make. A better value
> $scheme$host$uri$is_args$args" is much more reasonable, as the reverse
> proxy requests comes from many server {} with multiple server name and
> aliases.
>
> Shouldn't the default be changed?
The default key is to identify resources nginx requests from
upstream servers. That is, these are the same:
server {
server_name bar;
location / {
proxy_pass http://foo.example.com;
}
}
server {
server_name bazz;
location / {
proxy_pass http://foo.example.com;
}
}
While these are different:
server {
server_name foo;
location / {
set $backend "foo.example.com";
if ($user_is_admin) {
set $backend "admin.example.com";
}
proxy_pass http://$backed;
}
}
If in your case multiple such resources are equal or different
based on other factors (likely, due to "proxy_set_header Host ..."
in your configuration), you are free to change proxy_cache_key
accordingly.
--
Maxim Dounin
http://nginx.org/
More information about the nginx
mailing list