weight on the fly will have no effect, but this can be
changed using "hash-type".
- uri The left part of the URI (before the question mark) is hashed
- and divided by the total weight of the running servers. The
- result designates which server will receive the request. This
- ensures that a same URI will always be directed to the same
- server as long as no server goes up or down. This is used
- with proxy caches and anti-virus proxies in order to maximize
- the cache hit rate. Note that this algorithm may only be used
- in an HTTP backend. This algorithm is static by default,
- which means that changing a server's weight on the fly will
- have no effect, but this can be changed using "hash-type".
-
- This algorithm support two optional parameters "len" and
+ uri This algorithm hashes either the left part of the URI (before
+ the question mark) or the whole URI (if the "whole" parameter
+ is present) and divides the hash value by the total weight of
+ the running servers. The result designates which server will
+ receive the request. This ensures that the same URI will
+ always be directed to the same server as long as no server
+ goes up or down. This is used with proxy caches and
+ anti-virus proxies in order to maximize the cache hit rate.
+ Note that this algorithm may only be used in an HTTP backend.
+ This algorithm is static by default, which means that
+ changing a server's weight on the fly will have no effect,
+ but this can be changed using "hash-type".
+
+ This algorithm supports two optional parameters "len" and
"depth", both followed by a positive integer number. These
options may be helpful when it is needed to balance servers
based on the beginning of the URI only. The "len" parameter
unsigned url_param_post_limit; /* if checking POST body for URI parameter, max body to wait for */
int uri_len_limit; /* character limit for uri balancing algorithm */
int uri_dirs_depth1; /* directories+1 (slashes) limit for uri balancing algorithm */
+ int uri_whole; /* if != 0, calculates the hash from the whole uri. Still honors the len_limit and dirs_depth1 */
char *hh_name; /* name of the header parameter used for hashing */
int hh_len; /* strlen(hh_name), computed only once */
int hh_match_domain; /* toggle use of special match function */
if (slashes == px->uri_dirs_depth1) /* depth+1 */
break;
}
- else if (c == '?')
+ else if (c == '?' && !px->uri_whole)
break;
hash = c + (hash << 6) + (hash << 16) - hash;
curproxy->lbprm.algo &= ~BE_LB_ALGO;
curproxy->lbprm.algo |= BE_LB_ALGO_UH;
+ curproxy->uri_whole = 0;
+
while (*args[arg]) {
if (!strcmp(args[arg], "len")) {
if (!*args[arg+1] || (atoi(args[arg+1]) <= 0)) {
curproxy->uri_dirs_depth1 = atoi(args[arg+1]) + 1;
arg += 2;
}
+ else if (!strcmp(args[arg], "whole")) {
+ curproxy->uri_whole = 1;
+ arg += 1;
+ }
else {
- memprintf(err, "%s only accepts parameters 'len' and 'depth' (got '%s').", args[0], args[arg]);
+ memprintf(err, "%s only accepts parameters 'len', 'depth', and 'whole' (got '%s').", args[0], args[arg]);
return -1;
}
}