2

The documentation suggests that I can setup a HTTP check for a TCP backend.

The liveness of my backend is determined by a 405 Method Not allowed response when hitting a-app.com/ap_service

My config looks like this:

frontend app-api
    bind *:443
    mode tcp

    option tcplog
    default_backend app-api_backend


backend app-api_backend
    mode tcp
    option httpchk GET /app_service HTTP/1.1
    http-check expect status 405
    server a a-app.com:443  resolvers dns verify none inter 1000  check
    server b b-app.com:443  resolvers dns verify none inter 1000  check

However, in the logs I get:

Server app-api_backend/a is DOWN, reason: Layer7 invalid response, check duration: 1ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Server app-api_backend/b is DOWN, reason: Layer7 invalid response, check duration: 1ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
...
  • So, I understand that your HAProxy Health Checks failing due to error 405 Method Not Allowed. Not sure if this is already the reason: github.com/phpmyadmin/docker/issues/126, github.com/phpmyadmin/docker/issues/64. – U880D May 17 '18 at 8:21
  • not sure if i have understand correctly. here seems that every backend alive condition is a 405 response. server b reply 405 so it looks up while server a doesn't so it marked as down. – djv May 17 '18 at 8:29
  • djv, actually I get the same logs for both backends. When I copy and pasted it didn't add the line for server b. And just to confirm 405 is my expected response for my health check. – kaizenCoder May 17 '18 at 22:28
1

I think that your problem is that you expect haproxy to make HTTPS requests guessing that port 443 is served on it, while option httpchk does only plain HTTP requests.

Serve your app over plain HTTP on a different port, apart from HTTPS, make it available for haproxy node, and use HTTP for the checks.

See example in haproxy option httpchk docs:

    # Relay HTTPS traffic to Apache instance and check service availability
    # using HTTP request "OPTIONS * HTTP/1.1" on port 80.
    backend https_relay
        mode tcp
        option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www
        server apache1 192.168.1.1:443 check port 80

In your case it would be something like this:

    backend app-api_backend
        mode tcp
        option httpchk GET /app_service HTTP/1.1
        http-check expect status 405
        server a a-app.com:443  resolvers dns verify none inter 1000 check port 80
        server b b-app.com:443  resolvers dns verify none inter 1000 check port 80

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.