e3f8a145696e2420d34fbba6050330441c92c2ce
[openwrt-packages.git] /
1 commit a100980f50f92e588c2b60f20571e84bf749f3e3
2 Author: Lukas Tribus <lukas@ltri.eu>
3 Date:   Sat Oct 27 20:07:40 2018 +0200
4
5     BUG/MINOR: only auto-prefer last server if lb-alg is non-deterministic
6     
7     While "option prefer-last-server" only applies to non-deterministic load
8     balancing algorithms, 401/407 responses actually caused haproxy to prefer
9     the last server unconditionally.
10     
11     As this breaks deterministic load balancing algorithms like uri, this
12     patch applies the same condition here.
13     
14     Should be backported to 1.8 (together with "BUG/MINOR: only mark
15     connections private if NTLM is detected").
16     
17     (cherry picked from commit 80512b186fd7f4ef3bc7d9c92b281c549d72aa8a)
18     Signed-off-by: Willy Tarreau <w@1wt.eu>
19
20 diff --git a/doc/configuration.txt b/doc/configuration.txt
21 index 43b1b822..f0558d5e 100644
22 --- a/doc/configuration.txt
23 +++ b/doc/configuration.txt
24 @@ -2498,6 +2498,11 @@ balance url_param <param> [check_post]
25    algorithm, mode nor option have been set. The algorithm may only be set once
26    for each backend.
27  
28 +  With authentication schemes that require the same connection like NTLM, URI
29 +  based alghoritms must not be used, as they would cause subsequent requests
30 +  to be routed to different backend servers, breaking the invalid assumptions
31 +  NTLM relies on.
32 +
33    Examples :
34          balance roundrobin
35          balance url_param userid
36 @@ -6486,8 +6491,9 @@ no option prefer-last-server
37    close of the connection. This can make sense for static file servers. It does
38    not make much sense to use this in combination with hashing algorithms. Note,
39    haproxy already automatically tries to stick to a server which sends a 401 or
40 -  to a proxy which sends a 407 (authentication required). This is mandatory for
41 -  use with the broken NTLM authentication challenge, and significantly helps in
42 +  to a proxy which sends a 407 (authentication required), when the load
43 +  balancing algorithm is not deterministic. This is mandatory for use with the
44 +  broken NTLM authentication challenge, and significantly helps in
45    troubleshooting some faulty applications. Option prefer-last-server might be
46    desirable in these environments as well, to avoid redistributing the traffic
47    after every other response.
48 diff --git a/src/backend.c b/src/backend.c
49 index fc1eac0d..b3fd6c67 100644
50 --- a/src/backend.c
51 +++ b/src/backend.c
52 @@ -572,9 +572,9 @@ int assign_server(struct stream *s)
53         if (conn &&
54             (conn->flags & CO_FL_CONNECTED) &&
55             objt_server(conn->target) && __objt_server(conn->target)->proxy == s->be &&
56 +           (s->be->lbprm.algo & BE_LB_KIND) != BE_LB_KIND_HI &&
57             ((s->txn && s->txn->flags & TX_PREFER_LAST) ||
58              ((s->be->options & PR_O_PREF_LAST) &&
59 -              (s->be->lbprm.algo & BE_LB_KIND) != BE_LB_KIND_HI &&
60               (!s->be->max_ka_queue ||
61                server_has_room(__objt_server(conn->target)) ||
62                (__objt_server(conn->target)->nbpend + 1) < s->be->max_ka_queue))) &&
63 diff --git a/src/proto_http.c b/src/proto_http.c
64 index cde2dbf7..a48c4fdb 100644
65 --- a/src/proto_http.c
66 +++ b/src/proto_http.c
67 @@ -4385,7 +4385,8 @@ void http_end_txn_clean_session(struct stream *s)
68                  * server over the same connection. This is required by some
69                  * broken protocols such as NTLM, and anyway whenever there is
70                  * an opportunity for sending the challenge to the proper place,
71 -                * it's better to do it (at least it helps with debugging).
72 +                * it's better to do it (at least it helps with debugging), at
73 +                * least for non-deterministic load balancing algorithms.
74                  */
75                 s->txn->flags |= TX_PREFER_LAST;
76         }
git clone https://git.99rst.org/PROJECT