Hi,
i’ve run a few tests with the nginx proxy module. I would like to have
my content cached with the “$scheme$host$request_uri” key, like
suggested
on the wiki page[1]. So i’ve added the following:
proxy_cache_key “$scheme$host$request_uri”;
into the http {} block. After the test i’ve checked the keys which are
used
in the cached files and noticed that the key was
httpmy_vhost/original_request_uri
but i’ve a perl module which does a internal_redirect which rewrites
some
paths like /olddir/ to /.
Now we have the following request:
http//my_vhost/olddir/documents/test.pdf
so i thought the key should be
httpmy_vhost/documents/test.pdf
but it was
httpmy_vhost/olddir/documents/test.pdf
when i remove the proxy_cache_key from the config i get the following
key:
http://interal_host:internal_port/documents/test.pdf
so something here seems to be “strange”. Because the default key is:
default: $scheme$proxy_host$request_uri;
and now we see the following differences:
first: $scheme seems to be http when beeing used, but http:// when
default.
second: the $request_uri is not rewritten when defined as key, but it
seems
to be rewritten by default.
Seems like a bug to me…?
Regards,
Sven
Hi,
So i’ve added the following:
proxy_cache_key “$scheme$host$request_uri”;
Try using “$scheme$host$uri$is_args$args” ![:wink: :wink:](https://www.ruby-forum.com/images/emoji/apple/wink.png?v=12)
when i remove the proxy_cache_key from the config i get the following key:
http://interal_host:internal_port/documents/test.pdf
so something here seems to be “strange”. Because the default key is:
default: $scheme$proxy_host$request_uri;
No, default key isn’t calculated from variables…
It’s something like: “${proxy_scheme}://$proxy_host$uri$is_args$args”
Also, “$proxy_host” returns whatever you’ve got in your “proxy_pass”
directive, so in case you’ve got “proxy_pass http://127.0.0.1:8000” it
will
return “127.0.0.1:8000”.
first: $scheme seems to be http when beeing used, but http:// when
default.
See above.
second: the $request_uri is not rewritten when defined as key, but it
seems
to be rewritten by default.
“$request_uri” isn’t used in the default cache key.
Best regards,
Piotr S. < [email protected] >
Hi,
On 25/12/2010 03:29, Piotr S. wrote:
So i’ve added the following:
proxy_cache_key “$scheme$host$request_uri”;
Try using “$scheme$host$uri$is_args$args” ![:wink: :wink:](https://www.ruby-forum.com/images/emoji/apple/wink.png?v=12)
Probably putting ‘://’ or something else that won’t be the first
character of a URL (e.g. ‘#’) between $scheme and $host is a good idea,
just in case you have two hosts that only differ by an initial ‘s’ -
e.g. mysite.com and smysite.com
https + mysite.com = http + smysite.com
In most situations this will be fine, but depending on the setup, it
could potentially be a source of bugs or a security hole.
Marcus.
Hi,
Am 25.12.2010 04:48, schrieb Maxim D.:
[1] Модуль ngx_http_proxy_module
Aww, okay. So its a wiki documentation Bug.
Thanks a lot, works now.
Regards,
Sven
Hello!
On Fri, Dec 24, 2010 at 11:57:30PM +0100, Sven ‘Darkman’ Michels wrote:
httpmy_vhost/olddir/documents/test.pdf
to be rewritten by default.
Seems like a bug to me…?
Default listed in wiki/docs isn’t what actually used by default as
proxy_cache_key. In russian docs[1] you may find something like
By default value is similar to
proxy_cache_key $scheme$proxy_host$uri$is_args$args;
Word “similar” is key one. Actual value can’t be expressed with
variables. It’s something like $proxy_url - but there are no such
variable.
[1]
http://sysoev.ru/nginx/docs/http/ngx_http_proxy_module.html#proxy_cache_key
Maxim D.