chain_regex(&curproxy->req_exp, preg, ACT_TARPIT, NULL);
}
+ else if (!strcmp(args[0], "reqsetbe")) { /* switch the backend from a regex, respecting case */
+ regex_t *preg;
+ if(curproxy == &defproxy) {
+ Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
+ return -1;
+ }
+
+ if(*(args[1]) == 0 || *(args[2]) == 0) {
+ Alert("parsing [%s:%d] : '%s' expects <search> and <target> as arguments.\n",
+ file, linenum, args[0]);
+ return -1;
+ }
+
+ preg = calloc(1, sizeof(regex_t));
+ if(regcomp(preg, args[1], REG_EXTENDED) != 0) {
+ Alert("parsing [%s:%d] : bad regular expression '%s'.\n", file, linenum, args[1]);
+ }
+
+ chain_regex(&curproxy->req_exp, preg, ACT_SETBE, strdup(args[2]));
+ }
+ else if (!strcmp(args[0], "reqisetbe")) { /* switch the backend from a regex, ignoring case */
+ regex_t *preg;
+ if(curproxy == &defproxy) {
+ Alert("parsing [%s:%d] : '%s' not allowed in 'defaults' section.\n", file, linenum, args[0]);
+ return -1;
+ }
+
+ if(*(args[1]) == 0 || *(args[2]) == 0) {
+ Alert("parsing [%s:%d] : '%s' expects <search> and <target> as arguments.\n",
+ file, linenum, args[0]);
+ return -1;
+ }
+
+ preg = calloc(1, sizeof(regex_t));
+ if(regcomp(preg, args[1], REG_EXTENDED | REG_ICASE) != 0) {
+ Alert("parsing [%s:%d] : bad regular expression '%s'.\n", file, linenum, args[1]);
+ }
+
+ chain_regex(&curproxy->req_exp, preg, ACT_SETBE, strdup(args[2]));
+ }
else if (!strcmp(args[0], "reqirep")) { /* replace request header from a regex, ignoring case */
regex_t *preg;
if (curproxy == &defproxy) {
Alert("parsing [%s:%d] : unknown keyword '%s' out of section.\n", file, linenum, args[0]);
return -1;
}
-
-
}
fclose(f);
}
}
+ if (curproxy->mode == PR_MODE_HTTP && curproxy->req_exp != NULL) {
+ /* map jump target for ACT_SETBE in req_rep chain */
+ struct hdr_exp *exp;
+ struct proxy *target;
+ for (exp = curproxy->req_exp; exp != NULL; exp = exp->next) {
+ if (exp->action != ACT_SETBE)
+ continue;
+ for (target = proxy; target != NULL; target = target->next) {
+ if (strcmp(target->id, exp->replace) == 0)
+ break;
+ }
+ if (target == NULL) {
+ Alert("parsing %s : backend '%s' in HTTP proxy %s was not found !\n",
+ file, exp->replace, curproxy->id);
+ cfgerr++;
+ } else if (target == curproxy) {
+ Alert("parsing %s : loop detected for backend %s !\n", file, exp->replace);
+ cfgerr++;
+ } else {
+ free((void *)exp->replace);
+ exp->replace = (const char *)target;
+ }
+ }
+ }
if ((curproxy->mode == PR_MODE_TCP || curproxy->mode == PR_MODE_HTTP) &&
(!curproxy->clitimeout || !curproxy->contimeout || !curproxy->srvtimeout)) {
Warning("parsing %s : missing timeouts for listener '%s'.\n"
if (regexec(exp->preg, cur_ptr, MAX_MATCH, pmatch, 0) == 0) {
switch (exp->action) {
+ case ACT_SETBE:
+ /* It is not possible to jump a second time.
+ * FIXME: should we return an HTTP/500 here so that
+ * the admin knows there's a problem ?
+ */
+ if (t->be != t->fe)
+ break;
+
+ if (!(t->flags & (SN_CLDENY | SN_CLTARPIT))) {
+ struct proxy *target = (struct proxy *) exp->replace;
+
+ /* Swithing Proxy */
+ *cur_end = term;
+ cur_end = NULL;
+
+ /* right now, the backend switch is not too much complicated
+ * because we have associated req_cap and rsp_cap to the
+ * frontend, and the beconn will be updated later.
+ */
+
+ t->rep->rto = t->req->wto = target->beprm->srvtimeout;
+ t->req->cto = target->beprm->contimeout;
+
+ t->be = target;
+
+ //t->logs.logwait |= LW_REQ | (target->to_log & (LW_REQHDR | LW_COOKIE));
+ t->logs.logwait |= (target->to_log | target->beprm->to_log);
+ abort_filt = 1;
+ }
+ break;
case ACT_ALLOW:
if (!(t->flags & (SN_CLDENY | SN_CLTARPIT))) {
t->flags |= SN_CLALLOW;