diff --git a/doc/configuration.txt b/doc/configuration.txt index 47842d6c7..3c6dd642e 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -1503,7 +1503,7 @@ contimeout cookie [ rewrite | insert | prefix ] [ indirect ] [ nocache ] - [ postonly ] [ domain ] + [ postonly ] [ domain ]* Enable cookie-based persistence in a backend. May be used in sections : defaults | frontend | listen | backend yes | no | yes | yes @@ -1585,7 +1585,12 @@ cookie [ rewrite | insert | prefix ] [ indirect ] [ nocache ] domain This option allows to specify the domain at which a cookie is inserted. It requires exactly one paramater: a valid domain - name. + name. If the domain begins with a dot, the browser is allowed to + use it for any host ending with that name. It is also possible to + specify several domain names by invoking this option multiple + times. Some browsers might have small limits on the number of + domains, so be careful when doing that. For the record, sending + 10 domains to MSIE 6 or Firefox 2 works as expected. There can be only one persistence cookie per HTTP backend, and it can be declared in a defaults section. The value of the cookie will be the value diff --git a/src/cfgparse.c b/src/cfgparse.c index d433ea314..e74b7687a 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -1475,7 +1475,21 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) goto out; } - curproxy->cookie_domain = strdup(args[cur_arg + 1]); + if (!curproxy->cookie_domain) { + curproxy->cookie_domain = strdup(args[cur_arg + 1]); + } else { + /* one domain was already specified, add another one by + * building the string which will be returned along with + * the cookie. + */ + char *new_ptr; + int new_len = strlen(curproxy->cookie_domain) + + strlen("; domain=") + strlen(args[cur_arg + 1]) + 1; + new_ptr = malloc(new_len); + snprintf(new_ptr, new_len, "%s; domain=%s", curproxy->cookie_domain, args[cur_arg+1]); + free(curproxy->cookie_domain); + curproxy->cookie_domain = new_ptr; + } cur_arg++; } else {