You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
3.5 KiB

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