1

I want to migrate some websites to a new server. It takes a couple of days to get all the DNS changes done, so I wanted to set up a HAProxy reverse proxy to redirect all traffic from the old location to the new location. I'm not very experienced with such a config. When visiting a domain, I get an error saying:

503 Service Unavailable No server is available to handle this request.

This is the config I used (with hidden IP address):

global

  log         127.0.0.1 local2

    chroot  /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group   haproxy
    daemon

    # turn on stats unix socket
    stats socket /var/lib/haproxy/stats

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

frontend localhost
   bind *:80
   bind *:443 ssl crt /etc/pki/tls/certs/haproxy.pem
   redirect scheme https if !{ ssl_fc }
   mode http
   default_backend node

backend node
    mode http
    option forwardfor
    option httpchk HEAD / HTTP/1.1\r\nHost:localhost
    server dcnode1 x.x.x.x:80 check
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }

1
  • I got the exact same error when I visited that hidden IP address. It looks like whatever is listening on port 80 of that system, can't reach its backend servers. Aug 18, 2020 at 13:51

1 Answer 1

0

This error means that the backend is not considered 'up'.

First make sure that the backend server is running and accessible from the HAProxy machine, e.g. telnet x.x.x.x 80 and make sure it connects.

If you can successfully make a connection, the second thing to check is whether the backend is failing a check. Try removing option httpchk, and remove check from the server line. (When you've only got one backend server, a check isn't of huge value, but you can always add it back later)

It may be that your Host: localhost is returning something unusual in the check.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .