HAProxy 504 Timeout on Varnish Backends

I’m serving two websites through HAProxy and Varnish. There’s a wiki site and a wordpress site. The wiki site works continuously and without problem. However the WordPress site continuously shows a 504 error each time you reload the page.

If I spoof the wordpress site in my hosts file by using the IP of the varnish server instead of HAProxy the site comes back and starts working fine. It’s only when wordpress is on haproxy that the site 504’s.

Read More

I’d like to know how to turn on debug logging for HAProxy and also maybe get some help solving this problem.

This is all that I see in the logs for haproxy:

Apr  3 20:29:18 lb1.example.com haproxy[18501]: 52.21.231.226:52845 [03/Apr/2016:20:29:15.318] varnish-cluster varnish-cluster/varnish1 0/0/0/2786/2786 200 626 - - --NR 2/2/1/1/0 0/0 "HEAD / HTTP/1.1"
Apr  3 20:29:28 lb1.example.com haproxy[18501]: 61.174.10.22:18645 [03/Apr/2016:20:29:09.522] varnish-cluster varnish-cluster/varnish1 0/0/0/18206/19039 404 101736 - - --VN 0/0/0/0/0 0/0 "GET /groups/ HTTP/1.0"
Apr  3 20:29:34 lb1.example.com haproxy[18501]: 61.174.10.22:26372 [03/Apr/2016:20:29:31.045] varnish-cluster varnish-cluster/varnish1 0/0/0/3048/3048 301 549 - - --VN 0/0/0/0/0 0/0 "GET /members/pzwkathi09454/activity HTTP/1.0"
Apr  3 20:29:54 lb1.example.com haproxy[18501]: 61.174.10.22:27761 [03/Apr/2016:20:29:34.879] varnish-cluster varnish-cluster/varnish1 0/0/0/-1/20003 504 194 - - sHVN 0/0/0/0/0 0/0 "GET /activity/ HTTP/1.0"

And this is my config:

global
    log 127.0.0.1 local2 debug
    user root
    group root

defaults
    log global
    retries 2
    timeout connect 12000
    timeout server 20000
    timeout client 20000

listen varnish-cluster  0.0.0.0:80
    mode http
    stats enable
    stats uri /haproxy?stats
    stats realm Strictly Private
    stats auth admin:secret
    balance roundrobin
    option http-server-close
    timeout http-keep-alive 3000
    option forwardfor
    option httplog
    cookie PHPSESSID prefix
    server varnish1 xx.xx.xx.xx:80 cookie s1 check

listen mysql-master-cluster
    bind 0.0.0.0:3306
    mode tcp
    option mysql-check user haproxy_check
    balance roundrobin
    server mysql-master-1 xx.xx.xx.xx:3306 check
    server mysql-master-2 xx.xx.xx.xx:3306 check

I’d appreciate any advice you’d have in solving the 504 error with HAProxy!

Related posts