#define PR_O_COOK_INS 0x00000010 /* insert cookies when not accessing a server directly */
#define PR_O_COOK_PFX 0x00000020 /* rewrite all cookies by prefixing the right serverid */
#define PR_O_COOK_ANY (PR_O_COOK_RW | PR_O_COOK_IND | PR_O_COOK_INS | PR_O_COOK_PFX)
-#define PR_O_SMTP_CHK 0x00000040 /* use SMTP EHLO check for server health - pvandijk@vision6.com.au */
+#define PR_O_DISPATCH 0x00000040 /* use dispatch mode */
#define PR_O_KEEPALIVE 0x00000080 /* follow keep-alive sessions */
#define PR_O_FWDFOR 0x00000100 /* insert x-forwarded-for with client address */
#define PR_O_BIND_SRC 0x00000200 /* bind to a specific source address when connect()ing */
#define PR_O_NULLNOLOG 0x00000400 /* a connect without request will not be logged */
#define PR_O_COOK_NOC 0x00000800 /* add a 'Cache-control' header with the cookie */
#define PR_O_COOK_POST 0x00001000 /* don't insert cookies for requests other than a POST */
-#define PR_O_HTTP_CHK 0x00002000 /* use HTTP 'OPTIONS' method to check server health */
+/* unused: 0x00002000 */
#define PR_O_PERSIST 0x00004000 /* server persistence stays effective even when server is down */
#define PR_O_LOGASAP 0x00008000 /* log as soon as possible, without waiting for the session to complete */
#define PR_O_HTTP_CLOSE 0x00010000 /* force 'connection: close' in both directions */
#define PR_O2_AS_M_PP 0x00000000 /* path-parameters mode (the default mode) */
#define PR_O2_AS_M_QS 0x00010000 /* query-string mode */
#define PR_O2_AS_M_ANY 0x00010000 /* mask covering all PR_O2_AS_M_* values */
-
-#define PR_O2_MYSQL_CHK 0x00020000 /* use MYSQL check for server health */
+#define PR_O2_NODELAY 0x00020000 /* fully interactive mode, never delay outgoing data */
#define PR_O2_USE_PXHDR 0x00040000 /* use Proxy-Connection for proxy requests */
#define PR_O2_CHK_SNDST 0x00080000 /* send the state of each server along with HTTP health checks */
-#define PR_O2_SSL3_CHK 0x00100000 /* use SSLv3 CLIENT_HELLO packets for server health */
+/* unused: 0x00100000 */
#define PR_O2_FAKE_KA 0x00200000 /* pretend we do keep-alive with server eventhough we close */
-#define PR_O2_LDAP_CHK 0x00400000 /* use LDAP check for server health */
-
+/* unused: 0x00400000 */
#define PR_O2_EXP_NONE 0x00000000 /* http-check : no expect rule */
#define PR_O2_EXP_STS 0x00800000 /* http-check expect status */
#define PR_O2_EXP_RSTS 0x01000000 /* http-check expect rstatus */
#define PR_O2_EXP_INV 0x04000000 /* http-check expect !<rule> */
#define PR_O2_COOK_PSV 0x08000000 /* cookie ... preserve */
+/* server health checks */
+#define PR_O2_CHK_NONE 0x00000000 /* no L7 health checks configured (TCP by default) */
#define PR_O2_PGSQL_CHK 0x10000000 /* use PGSQL check for server health */
-#define PR_O2_DISPATCH 0x20000000 /* use dispatch mode */
-#define PR_O2_NODELAY 0x40000000 /* fully interactive mode, never delay outgoing data */
-#define PR_O2_REDIS_CHK 0x80000000 /* use LDAP check for server health */
+#define PR_O2_REDIS_CHK 0x20000000 /* use LDAP check for server health */
+#define PR_O2_SMTP_CHK 0x30000000 /* use SMTP EHLO check for server health - pvandijk@vision6.com.au */
+#define PR_O2_HTTP_CHK 0x40000000 /* use HTTP 'OPTIONS' method to check server health */
+#define PR_O2_MYSQL_CHK 0x50000000 /* use MYSQL check for server health */
+#define PR_O2_LDAP_CHK 0x60000000 /* use LDAP check for server health */
+#define PR_O2_SSL3_CHK 0x70000000 /* use SSLv3 CLIENT_HELLO packets for server health */
+/* unused: 0x80000000 to 0xF000000, reserved for health checks */
+#define PR_O2_CHK_ANY 0xF0000000 /* Mask to cover any check */
/* end of proxy->options2 */
/* bits for sticking rules */
/* use HTTP request to check servers' health */
free(curproxy->check_req);
curproxy->check_req = NULL;
- curproxy->options &= ~PR_O_SMTP_CHK;
- curproxy->options2 &= ~PR_O2_SSL3_CHK;
- curproxy->options2 &= ~PR_O2_MYSQL_CHK;
- curproxy->options2 &= ~PR_O2_PGSQL_CHK;
- curproxy->options2 &= ~PR_O2_LDAP_CHK;
- curproxy->options2 &= ~PR_O2_REDIS_CHK;
- curproxy->options |= PR_O_HTTP_CHK;
+ curproxy->options2 &= ~PR_O2_CHK_ANY;
+ curproxy->options2 |= PR_O2_HTTP_CHK;
if (!*args[2]) { /* no argument */
curproxy->check_req = strdup(DEF_CHECK_REQ); /* default request */
curproxy->check_len = strlen(DEF_CHECK_REQ);
free(curproxy->check_req);
curproxy->check_req = NULL;
- curproxy->options &= ~PR_O_HTTP_CHK;
- curproxy->options &= ~PR_O_SMTP_CHK;
- curproxy->options2 &= ~PR_O2_MYSQL_CHK;
- curproxy->options2 &= ~PR_O2_PGSQL_CHK;
- curproxy->options2 &= ~PR_O2_LDAP_CHK;
- curproxy->options2 &= ~PR_O2_REDIS_CHK;
+ curproxy->options2 &= ~PR_O2_CHK_ANY;
curproxy->options2 |= PR_O2_SSL3_CHK;
}
else if (!strcmp(args[1], "smtpchk")) {
/* use SMTP request to check servers' health */
free(curproxy->check_req);
curproxy->check_req = NULL;
- curproxy->options &= ~PR_O_HTTP_CHK;
- curproxy->options2 &= ~PR_O2_SSL3_CHK;
- curproxy->options2 &= ~PR_O2_MYSQL_CHK;
- curproxy->options2 &= ~PR_O2_PGSQL_CHK;
- curproxy->options2 &= ~PR_O2_LDAP_CHK;
- curproxy->options2 &= ~PR_O2_REDIS_CHK;
- curproxy->options |= PR_O_SMTP_CHK;
+ curproxy->options2 &= ~PR_O2_CHK_ANY;
+ curproxy->options2 |= PR_O2_SMTP_CHK;
if (!*args[2] || !*args[3]) { /* no argument or incomplete EHLO host */
curproxy->check_req = strdup(DEF_SMTP_CHECK_REQ); /* default request */
free(curproxy->check_req);
curproxy->check_req = NULL;
- curproxy->options &= ~PR_O_HTTP_CHK;
- curproxy->options &= ~PR_O_SMTP_CHK;
- curproxy->options2 &= ~PR_O2_SSL3_CHK;
- curproxy->options2 &= ~PR_O2_LDAP_CHK;
- curproxy->options2 &= ~PR_O2_REDIS_CHK;
- curproxy->options2 &= ~PR_O2_MYSQL_CHK;
+ curproxy->options2 &= ~PR_O2_CHK_ANY;
curproxy->options2 |= PR_O2_PGSQL_CHK;
if (*(args[2])) {
free(curproxy->check_req);
curproxy->check_req = NULL;
- curproxy->options &= ~PR_O_HTTP_CHK;
- curproxy->options &= ~PR_O_SMTP_CHK;
- curproxy->options2 &= ~PR_O2_SSL3_CHK;
- curproxy->options2 &= ~PR_O2_MYSQL_CHK;
- curproxy->options2 &= ~PR_O2_PGSQL_CHK;
- curproxy->options2 &= ~PR_O2_LDAP_CHK;
+ curproxy->options2 &= ~PR_O2_CHK_ANY;
curproxy->options2 |= PR_O2_REDIS_CHK;
curproxy->check_req = (char *) malloc(sizeof(DEF_REDIS_CHECK_REQ) - 1);
free(curproxy->check_req);
curproxy->check_req = NULL;
- curproxy->options &= ~PR_O_HTTP_CHK;
- curproxy->options &= ~PR_O_SMTP_CHK;
- curproxy->options2 &= ~PR_O2_SSL3_CHK;
- curproxy->options2 &= ~PR_O2_LDAP_CHK;
- curproxy->options2 &= ~PR_O2_REDIS_CHK;
- curproxy->options2 &= ~PR_O2_PGSQL_CHK;
+ curproxy->options2 &= ~PR_O2_CHK_ANY;
curproxy->options2 |= PR_O2_MYSQL_CHK;
/* This is an exemple of an MySQL >=4.0 client Authentication packet kindly provided by Cyril Bonte.
/* use LDAP request to check servers' health */
free(curproxy->check_req);
curproxy->check_req = NULL;
- curproxy->options &= ~PR_O_HTTP_CHK;
- curproxy->options &= ~PR_O_SMTP_CHK;
- curproxy->options2 &= ~PR_O2_SSL3_CHK;
- curproxy->options2 &= ~PR_O2_MYSQL_CHK;
- curproxy->options2 &= ~PR_O2_PGSQL_CHK;
- curproxy->options2 &= ~PR_O2_REDIS_CHK;
+ curproxy->options2 &= ~PR_O2_CHK_ANY;
curproxy->options2 |= PR_O2_LDAP_CHK;
curproxy->check_req = (char *) malloc(sizeof(DEF_LDAP_CHECK_REQ) - 1);
goto out;
}
curproxy->dispatch_addr = *sk;
- curproxy->options2 |= PR_O2_DISPATCH;
+ curproxy->options |= PR_O_DISPATCH;
}
else if (!strcmp(args[0], "balance")) { /* set balancing with optional algorithm */
if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL))
cfgerr++;
}
#endif
- else if (curproxy->options2 & PR_O2_DISPATCH) {
+ else if (curproxy->options & PR_O_DISPATCH) {
Warning("config : dispatch address of %s '%s' will be ignored in balance mode.\n",
proxy_type_str(curproxy), curproxy->id);
err_code |= ERR_WARN;
}
}
- else if (!(curproxy->options & (PR_O_TRANSP | PR_O_HTTP_PROXY)) &&
- !(curproxy->options2 & PR_O2_DISPATCH)) {
+ else if (!(curproxy->options & (PR_O_TRANSP | PR_O_DISPATCH | PR_O_HTTP_PROXY))) {
/* If no LB algo is set in a backend, and we're not in
* transparent mode, dispatch mode nor proxy mode, we
* want to use balance roundrobin by default.
}
}
- if (curproxy->options2 & PR_O2_DISPATCH) {
- curproxy->options &= ~PR_O_TRANSP;
- curproxy->options &= ~PR_O_HTTP_PROXY;
- }
- else if (curproxy->options & PR_O_HTTP_PROXY) {
- curproxy->options2 &= ~PR_O2_DISPATCH;
- curproxy->options &= ~PR_O_TRANSP;
- }
- else if (curproxy->options & PR_O_TRANSP) {
- curproxy->options2 &= ~PR_O2_DISPATCH;
- curproxy->options &= ~PR_O_HTTP_PROXY;
- }
-
- if ((curproxy->options & PR_O_DISABLE404) && !(curproxy->options & PR_O_HTTP_CHK)) {
- curproxy->options &= ~PR_O_DISABLE404;
- Warning("config : '%s' will be ignored for %s '%s' (requires 'option httpchk').\n",
- "disable-on-404", proxy_type_str(curproxy), curproxy->id);
- err_code |= ERR_WARN;
- }
+ if (curproxy->options & PR_O_DISPATCH)
+ curproxy->options &= ~(PR_O_TRANSP | PR_O_HTTP_PROXY);
+ else if (curproxy->options & PR_O_HTTP_PROXY)
+ curproxy->options &= ~(PR_O_DISPATCH | PR_O_TRANSP);
+ else if (curproxy->options & PR_O_TRANSP)
+ curproxy->options &= ~(PR_O_DISPATCH | PR_O_HTTP_PROXY);
- if ((curproxy->options2 & PR_O2_CHK_SNDST) && !(curproxy->options & PR_O_HTTP_CHK)) {
- curproxy->options &= ~PR_O2_CHK_SNDST;
- Warning("config : '%s' will be ignored for %s '%s' (requires 'option httpchk').\n",
- "send-state", proxy_type_str(curproxy), curproxy->id);
- err_code |= ERR_WARN;
+ if ((curproxy->options2 & PR_O2_CHK_ANY) != PR_O2_HTTP_CHK) {
+ if (curproxy->options & PR_O_DISABLE404) {
+ Warning("config : '%s' will be ignored for %s '%s' (requires 'option httpchk').\n",
+ "disable-on-404", proxy_type_str(curproxy), curproxy->id);
+ err_code |= ERR_WARN;
+ curproxy->options &= ~PR_O_DISABLE404;
+ }
+ if (curproxy->options2 & PR_O2_CHK_SNDST) {
+ Warning("config : '%s' will be ignored for %s '%s' (requires 'option httpchk').\n",
+ "send-state", proxy_type_str(curproxy), curproxy->id);
+ err_code |= ERR_WARN;
+ curproxy->options &= ~PR_O2_CHK_SNDST;
+ }
}
/* if a default backend was specified, let's find it */
}
}
- if (curproxy->options2 & PR_O2_SSL3_CHK) {
+ if ((curproxy->options2 & PR_O2_CHK_ANY) == PR_O2_SSL3_CHK) {
curproxy->check_len = sizeof(sslv3_client_hello_pkt) - 1;
curproxy->check_req = (char *)malloc(curproxy->check_len);
memcpy(curproxy->check_req, sslv3_client_hello_pkt, curproxy->check_len);
if (!(s->result & SRV_CHK_ERROR)) {
/* we don't want to mark 'UP' a server on which we detected an error earlier */
- if ((s->proxy->options & PR_O_HTTP_CHK) ||
- (s->proxy->options & PR_O_SMTP_CHK) ||
- (s->proxy->options2 & PR_O2_SSL3_CHK) ||
- (s->proxy->options2 & PR_O2_MYSQL_CHK) ||
- (s->proxy->options2 & PR_O2_PGSQL_CHK) ||
- (s->proxy->options2 & PR_O2_REDIS_CHK) ||
- (s->proxy->options2 & PR_O2_LDAP_CHK)) {
+ if (s->proxy->options2 & PR_O2_CHK_ANY) {
int ret;
const char *check_req = s->proxy->check_req;
int check_len = s->proxy->check_len;
* so we'll send the request, and won't wake the checker up now.
*/
- if (s->proxy->options2 & PR_O2_SSL3_CHK) {
+ if ((s->proxy->options2 & PR_O2_CHK_ANY) == PR_O2_SSL3_CHK) {
/* SSL requires that we put Unix time in the request */
int gmt_time = htonl(date.tv_sec);
memcpy(s->proxy->check_req + 11, &gmt_time, 4);
}
- else if (s->proxy->options & PR_O_HTTP_CHK) {
+ else if ((s->proxy->options2 & PR_O2_CHK_ANY) == PR_O2_HTTP_CHK) {
memcpy(trash, check_req, check_len);
if (s->proxy->options2 & PR_O2_CHK_SNDST)
}
/* Run the checks... */
- if (s->proxy->options & PR_O_HTTP_CHK) {
+ switch (s->proxy->options2 & PR_O2_CHK_ANY) {
+ case PR_O2_HTTP_CHK:
if (!done && s->check_data_len < strlen("HTTP/1.0 000\r"))
goto wait_more_data;
cut_crlf(desc);
set_server_check_status(s, HCHK_STATUS_L7STS, desc);
}
- }
- else if (s->proxy->options2 & PR_O2_SSL3_CHK) {
+ break;
+
+ case PR_O2_SSL3_CHK:
if (!done && s->check_data_len < 5)
goto wait_more_data;
set_server_check_status(s, HCHK_STATUS_L6OK, NULL);
else
set_server_check_status(s, HCHK_STATUS_L6RSP, NULL);
- }
- else if (s->proxy->options & PR_O_SMTP_CHK) {
+ break;
+
+ case PR_O2_SMTP_CHK:
if (!done && s->check_data_len < strlen("000\r"))
goto wait_more_data;
set_server_check_status(s, HCHK_STATUS_L7OKD, desc);
else
set_server_check_status(s, HCHK_STATUS_L7STS, desc);
- }
- else if (s->proxy->options2 & PR_O2_PGSQL_CHK) {
+ break;
+
+ case PR_O2_PGSQL_CHK:
if (!done && s->check_data_len < 9)
goto wait_more_data;
set_server_check_status(s, HCHK_STATUS_L7STS, desc);
}
- }
- else if (s->proxy->options2 & PR_O2_REDIS_CHK) {
+ break;
+
+ case PR_O2_REDIS_CHK:
if (!done && s->check_data_len < 7)
goto wait_more_data;
else {
set_server_check_status(s, HCHK_STATUS_L7STS, s->check_data);
}
- }
- else if (s->proxy->options2 & PR_O2_MYSQL_CHK) {
+ break;
+
+ case PR_O2_MYSQL_CHK:
if (!done && s->check_data_len < 5)
goto wait_more_data;
set_server_check_status(s, HCHK_STATUS_L7RSP, desc);
}
}
- }
- else if (s->proxy->options2 & PR_O2_LDAP_CHK) {
+ break;
+
+ case PR_O2_LDAP_CHK:
if (!done && s->check_data_len < 14)
goto wait_more_data;
set_server_check_status(s, HCHK_STATUS_L7OKD, "Success");
}
}
- }
- else {
+ break;
+
+ default:
/* other checks are valid if the connection succeeded anyway */
set_server_check_status(s, HCHK_STATUS_L4OK, NULL);
- }
+ break;
+ } /* switch */
out_wakeup:
if (s->result & SRV_CHK_ERROR)
if (!EV_FD_ISSET(fd, DIR_RD)) {
set_server_check_status(s, HCHK_STATUS_L4TOUT, NULL);
} else {
- if (s->proxy->options2 & PR_O2_SSL3_CHK)
+ if ((s->proxy->options2 & PR_O2_CHK_ANY) == PR_O2_SSL3_CHK)
set_server_check_status(s, HCHK_STATUS_L6TOUT, NULL);
else /* HTTP, SMTP */
set_server_check_status(s, HCHK_STATUS_L7TOUT, NULL);