mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-17 11:06:54 +00:00
[MINOR] add configuration support for "redir" server keyword
The servers now support the "redir" keyword, making it possible to return a 302 with the specified prefix in front of the request instead of connecting to them. This is generally useful for multi-site load balancing but may also serve in order to achieve very high traffic rate. The keyword has only been added to the config parser and to structures, it's not used yet.
This commit is contained in:
parent
d2a4aa2c09
commit
7a58a72e85
@ -2,7 +2,7 @@
|
||||
include/types/server.h
|
||||
This file defines everything related to servers.
|
||||
|
||||
Copyright (C) 2000-2007 Willy Tarreau - w@1wt.eu
|
||||
Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
@ -73,7 +73,9 @@ struct server {
|
||||
int state; /* server state (SRV_*) */
|
||||
int prev_state; /* server state before last change (SRV_*) */
|
||||
int cklen; /* the len of the cookie, to speed up checks */
|
||||
int rdr_len; /* the length of the redirection prefix */
|
||||
char *cookie; /* the id set in the cookie */
|
||||
char *rdr_pfx; /* the redirection prefix */
|
||||
|
||||
struct proxy *proxy; /* the proxy this server belongs to */
|
||||
int cur_sess, cur_sess_max; /* number of currently active sessions (including syn_sent) */
|
||||
|
@ -1547,6 +1547,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
|
||||
newsrv->cklen = strlen(args[cur_arg + 1]);
|
||||
cur_arg += 2;
|
||||
}
|
||||
else if (!strcmp(args[cur_arg], "redir")) {
|
||||
newsrv->rdr_pfx = strdup(args[cur_arg + 1]);
|
||||
newsrv->rdr_len = strlen(args[cur_arg + 1]);
|
||||
cur_arg += 2;
|
||||
}
|
||||
else if (!strcmp(args[cur_arg], "rise")) {
|
||||
newsrv->rise = atol(args[cur_arg + 1]);
|
||||
newsrv->health = newsrv->rise;
|
||||
@ -1691,7 +1696,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
Alert("parsing [%s:%d] : server %s only supports options 'backup', 'cookie', 'check', 'inter', 'fastinter', 'downinter', 'rise', 'fall', 'addr', 'port', 'source', 'minconn', 'maxconn', 'maxqueue', 'slowstart' and 'weight'.\n",
|
||||
Alert("parsing [%s:%d] : server %s only supports options 'backup', 'cookie', 'redir', 'check', 'inter', 'fastinter', 'downinter', 'rise', 'fall', 'addr', 'port', 'source', 'minconn', 'maxconn', 'maxqueue', 'slowstart' and 'weight'.\n",
|
||||
file, linenum, newsrv->id);
|
||||
return -1;
|
||||
}
|
||||
@ -2904,6 +2909,19 @@ int readcfgfile(const char *file)
|
||||
if (curproxy->options & PR_O_LOGASAP)
|
||||
curproxy->to_log &= ~LW_BYTES;
|
||||
|
||||
/*
|
||||
* ensure that we're not cross-dressing a TCP server into HTTP.
|
||||
*/
|
||||
newsrv = curproxy->srv;
|
||||
while (newsrv != NULL) {
|
||||
if ((curproxy->mode != PR_MODE_HTTP) && (newsrv->rdr_len || newsrv->cklen)) {
|
||||
Alert("parsing %s, %s '%s' : server cannot have cookie or redirect prefix in non-HTTP mode.\n",
|
||||
file, proxy_type_str(curproxy), curproxy->id, linenum);
|
||||
goto err;
|
||||
}
|
||||
newsrv = newsrv->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* If this server supports a maxconn parameter, it needs a dedicated
|
||||
* tasks to fill the emptied slots when a connection leaves.
|
||||
|
Loading…
Reference in New Issue
Block a user