Upstream hash on portion of URL

I’d like to use the Upstream Hash Module, but have the hash be based
on just a portion of the URL.

For example, I have urls of the form:

http://server/foo/hash_part1/hash_part2/remainder/of/url/

and I’d like the hash to be based on ‘hash_part1’ and ‘hash_part2’.

Looking at the module doc, it takes a variable to do the hash on. Is
there any way to set a variable based on a regex expression? Or is
there another easy way to do this?

Thanks.

Scott Royston <scott.royston@…> writes:

Looking at the module doc, it takes a variable to do the hash on. Is
there any way to set a variable based on a regex expression? Or is
there another easy way to do this?

Thanks.

Try something like

if ($request_uri ~ /foo/(.?)/(.?)/remainder) {
set $hash1 $1;
set $hash2 $2;
hash “$hash1 $hash2”;
}

In any event, check out
http://wiki.codemongers.com/NginxHttpRewriteModule

Evan