default_backend X X X -
description - X X X
disabled X X X X
-dispatch - - X X
+dispatch (deprecated) - - X X
email-alert from X X X X
email-alert level X X X X
email-alert mailers X X X X
See also : "enabled"
-dispatch <address>:<port>
+dispatch <address>:<port> (deprecated)
Set a default server address
May be used in the following contexts: tcp, http
syntax, it has also been used for simple TCP relays. It is recommended not to
use it for more clarity, and to use the "server" directive instead.
+ This keyword has been deprecated in 3.3 and will be removed in 3.5 due to
+ some internal limitations (no support for SSL nor idle connections etc).
+ Using it will emit a warning that may be silenced by enabling directive
+ "expose-deprecated-directives" in the global section.
+
+ The correct way to proceed without this directive is to simply declare a
+ server with the same address and port. If the "dispatch" directive was
+ mixed with other servers, then these servers should be configured with a
+ weight of zero in order never to be elected by the load balancing algorithm.
+
+ Example:
+ backend deprecated_setup
+ dispatch 192.168.100.100:80 # external load balancer's address
+ server s1 192.168.100.1:80 cookie S1 check
+ server s2 192.168.100.2:80 cookie S2 check
+
+ backend modern_setup
+ server external_lb 192.168.100.100:80
+ server s1 192.168.100.1:80 cookie S1 check weight 0
+ server s2 192.168.100.2:80 cookie S2 check weight 0
+
See also : "server"
} -start
haproxy h1 -conf {
+global
+ # this is needed since 3.3, and this test will be removed in 3.5.
+ expose-deprecated-directives
+
defaults
log global
timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
feature ignore_unknown_macro
haproxy h1 -conf {
+ global
+ nbthread 1
+
defaults
timeout client 30s
timeout server 30s
timeout connect 30s
mode http
- listen sender
- bind "fd@${feS}"
+ listen sender1
+ bind "fd@${feN}"
+ http-reuse never
+ http-request set-header client-id %[req.hdr(client-id)] if { req.hdr(client-id) -m found }
+ server dispatch ${h1_feR_addr}:${h1_feR_port}
+
+ listen sender2
+ bind "fd@${feA}"
+ http-reuse always
http-request set-header client-id %[req.hdr(client-id)] if { req.hdr(client-id) -m found }
- dispatch ${h1_feR_addr}:${h1_feR_port}
+ server dispatch ${h1_feR_addr}:${h1_feR_port}
listen receiver
bind "fd@${feR}"
http-after-response set-header client-id %[var(sess.client_id)]
} -start
-client c1 -connect ${h1_feS_sock} {
+### http-reuse never
+client c1 -connect ${h1_feN_sock} {
txreq \
-hdr "client-id: c1"
rxresp
expect resp.http.client-id == "c1"
} -run
-client c2 -connect ${h1_feS_sock} {
+client c2 -connect ${h1_feN_sock} {
txreq \
-hdr "client-id: c2"
rxresp
expect resp.http.client-id == "c2"
} -run
-client c3 -connect ${h1_feS_sock} {
+client c3 -connect ${h1_feN_sock} {
txreq \
-hdr "client-id: c3"
rxresp
expect resp.http.http_first_request == "0"
expect resp.http.client-id == "c3"
} -run
+
+### http-reuse always
+client c4 -connect ${h1_feA_sock} {
+ txreq \
+ -hdr "client-id: c4"
+ rxresp
+ expect resp.http.http_first_request == "1"
+
+ txreq
+ rxresp
+ expect resp.http.http_first_request == "0"
+ expect resp.http.client-id == "c4"
+
+ txreq
+ rxresp
+ expect resp.http.http_first_request == "0"
+ expect resp.http.client-id == "c4"
+} -run
+
+client c5 -connect ${h1_feA_sock} {
+ txreq \
+ -hdr "client-id: c5"
+ rxresp
+ expect resp.http.http_first_request == "0"
+ expect resp.http.client-id == "c5"
+
+ txreq
+ rxresp
+ expect resp.http.http_first_request == "0"
+ expect resp.http.client-id == "c5"
+
+ txreq
+ rxresp
+ expect resp.http.http_first_request == "0"
+ expect resp.http.client-id == "c5"
+} -run
+
+client c6 -connect ${h1_feA_sock} {
+ txreq \
+ -hdr "client-id: c6"
+ rxresp
+ expect resp.http.http_first_request == "0"
+ expect resp.http.client-id == "c6"
+
+ txreq
+ rxresp
+ expect resp.http.http_first_request == "0"
+ expect resp.http.client-id == "c6"
+
+ txreq
+ rxresp
+ expect resp.http.http_first_request == "0"
+ expect resp.http.client-id == "c6"
+} -run
if (alertif_too_many_args(1, file, linenum, args, &err_code))
goto out;
+ if (!deprecated_directives_allowed) {
+ ha_warning("parsing [%s:%d]: '%s' is deprecated in 3.3 and will be removed in 3.5. "
+ "The modern way to do the same is to create a server with the same address, and "
+ "possibly to assign any extra server a weight of zero if any:\n"
+ " server dispatch %s\n"
+ "Note that it is still possible to silence this warning by setting "
+ "'expose-deprecated-directives' in the 'global' section, but do not wait to fix "
+ "your configuration!\n",
+ file, linenum, args[0], args[1]);
+ err_code |= ERR_WARN;
+ }
+
curproxy->dispatch_addr = *sk;
curproxy->options |= PR_O_DISPATCH;
}