gray_malkin
gray_malkin

Reputation: 109

do all backend servers have to be up for haproxy startup?

I'm trying to start a Haproxy loadbalancer with the following configuration:

global
  log 127.0.0.1 local0
  log 127.0.0.1 local0 notice

resolvers docker
  nameserver dnsmasq 1.2.3.4:53

defaults
  mode http
  log global
  option httplog
  option  dontlognull

frontend ft_radix_real
  bind *:61616
  maxconn 6000
  acl is_websocket hdr(Upgrade) -i WebSocket
  acl is_websocket hdr_beg(Host) -i ws
  use_backend bk_radix_real if is_websocket

backend bk_radix_real
  balance roundrobin
  option forwardfor
  server radix-real-1 1.2.3.4:1884 check resolvers docker resolve-prefer ipv4
  server radix-real-2 1.2.3.4:1884 check resolvers docker resolve-prefer ipv4
  server radix-real-3 1.2.3.4:1884 check resolvers docker resolve-prefer ipv4
  server radix-real-4 1.2.3.4:1884 check resolvers docker resolve-prefer ipv4

listen stats
   mode http
   option httplog
   option  dontlognull
   bind *:1936
   stats enable
   stats scope ft_radix_real
   stats scope bk_radix_real
   stats uri /
   stats realm Haproxy\ Statistics
   stats auth admin:admin

This configuration works when all backend servers are up. However, I would like to be able to start Haproxy even if some(NOT ALL) of the backend servers are not running. I checked the configuration document but couldn't find a solution. Is it possible?

Upvotes: 2

Views: 1538

Answers (3)

Enrico
Enrico

Reputation: 61

@abinet answer is still valid on 2.7 with a little change. As per documentation: https://docs.haproxy.org/2.7/configuration.html#5.2-init-addr

defaults
    # never fail on address resolution
    default-server init-addr last,libc,none

Upvotes: 1

abinet
abinet

Reputation: 2808

Since 1.7 you can start HAproxy without resolving all the hosts on startup:

defaults # never fail on address resolution default-server init-addr none

https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#init-addr

Upvotes: 4

Willy Tarreau
Willy Tarreau

Reputation: 3424

I don't see any problem, the checks are there for this. Servers will be checked, the dead ones will be marked down and only the remaining valid ones will handle the traffic. You probably need to describe what type of issue you're facing exactly.

Upvotes: 0

Related Questions