1

HAproxy should use httpchk against a page that requires authentication via basic auth.

backend backendname
    option httpchk
    http-check send meth GET uri /check/path/ ver HTTP/1.1 hdr Authorization 'Basic [base64 of the credentials]'
    http-check expect status 200

    server [server1-name] [server1-IP:PORT] check inter 10s rise 2 fall 1 maxconn 4
    server [server2-name] [server2-IP:PORT] check inter 10s rise 2 fall 1 maxconn 4

HAproxy does not get the right response and the servers are unavailable.

The HAproxy configuration (server name, IPs, ports, etc..) apart from the http-check part is most likely not the problem, as HAproxy worked with that settings before.

Testing with curl http://localhost:PORT --header "Authorization: Basic [base64 of the credentials]" on the server1 and server2 gets a 200 response.

Running the same HAproxy configuration against a script logging the headers of all received requests shows the exact same headers for the above curl call or HAproxy.

Veera Nagireddy
  • 523
  • 2
  • 6
  • Questions seeking installation, configuration or diagnostic help must include the desired end state, the specific problem or error, sufficient information about the configuration and environment to reproduce it, and attempted solutions. Questions without a clear problem statement are not useful to other readers and are unlikely to get good answers. – djdomi Aug 27 '22 at 18:17

1 Answers1

0
echo -n "my_username:my_password" | base64

http-check send meth GET uri /api/v1/status ver HTTP/1.0 hdr Authorization  'Basic base64ofthecredentials'

Works well for me.

haproxy -v
HAProxy version 2.6.7-c55bfdb 2022/12/02 - https://haproxy.org/
Status: long-term supported branch - will stop receiving fixes around Q2 2027.
Known bugs: http://www.haproxy.org/bugs/bugs-2.6.7.html
Running on: Linux 4.14.238-182.422.amzn2.x86_64 #1 SMP Tue Jul 20 20:35:54 UTC 2021 x86_64```
yuliys
  • 1
  • 1