11

here is my config file

listen  solr 0.0.0.0:8983
mode http
balance roundrobin
option httpchk GET "/solr/select/?q=id:1234" HTTP/1.1
server solr_slave 1.1.1.1:8983 maxconn 5000 weight 256 check
server solr_master 2.2.2.2:8983 maxconn 5000 weight 1 check

the problem is that my solr server is protected using basic http password authentication and hence the health check fails always

how do i tell haproxy to use those credentials during the health checks?

Mike Baranczak
  • 8,291
  • 8
  • 47
  • 71
Sanket Gupta
  • 573
  • 3
  • 6
  • 21

1 Answers1

19

A little late, but I just came across the same problem, and wanted to share the solution with the world. First, you base64-encode the credentials:

$ echo -n "user:pass" | base64
dXNlcjpwYXNz

(Make sure you use the -n switch so you don't append a newline.)

The option httpchk allows you to add arbitrary HTTP headers to the request; this feature isn't documented very well. (According to this discussion, future versions of Haproxy might get a more user-friendly method.) To use basic authentication:

option httpchk GET /solr/ HTTP/1.0\r\nAuthorization:\ Basic\ dXNlcjpwYXNz

Note that I used HTTP 1.0; for 1.1, you also need a Host header.

Mike Baranczak
  • 8,291
  • 8
  • 47
  • 71