mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-19 12:16:59 +00:00
[MINOR] config: support passing multiple "domain" statements to cookies
In some environments it is not possible to rely on any wildcard for a
domain name (eg: .com, .net, .fr...) so it is required to send multiple
domain extensions. (Un)fortunately the syntax check on the domain name
prevented that from being done the dirty way. So let's just build a
domain list when multiple domains are passed on the same line.
(cherry picked from commit 950245ca2b
)
This commit is contained in:
parent
4d187ac350
commit
68a897b2be
@ -1503,7 +1503,7 @@ contimeout <timeout>
|
||||
|
||||
|
||||
cookie <name> [ rewrite | insert | prefix ] [ indirect ] [ nocache ]
|
||||
[ postonly ] [ domain <domain> ]
|
||||
[ postonly ] [ domain <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 <name> [ 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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user