Haproxy solr authentication test with authentication

here is my configuration 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 therefore the health check is not always performed

how can I tell haproxy to use these credentials during health checks?

+8
haproxy
source share
1 answer

A little late, but I ran into 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 to not add a new line.)

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

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

Please note that I used HTTP 1.0; for version 1.1 you also need a node header.

+12
source share

All Articles