1

I'm trying to setup haproxy for the first time, and it has been giving me a lot of trouble. Right now, when I call the haproxy file in the /etc/init.d folder to start it up, I get the following:

$ ./haproxy start
  Starting haproxy:           [FAILED]

I've confirmed that chef installed haproxy:

$ haproxy -v
  HA-Proxy version 1.5.18 2016/05/10
  Copyright 2000-2016 Willy Tarreau <willy@haproxy.org>

To investigating further, I used the following commands:

$ haproxy -c -f /etc/haproxy/haproxy.cfg
  [WARNING] 023/190620 (24869) : parsing [/etc/haproxy/haproxy.cfg:19] : 'option httplog' not usable with frontend 'https' (needs 'mode http'). Falling back to 'option tcplog'. 
  Configuration file is valid

$ ha proxy -db -f /etc/haproxy/haproxy.cfg
  [WARNING] 023/190810 (25554) : parsing [/etc/haproxy/haproxy.cfg:19] : 'option httplog' not usable with frontend 'https' (needs 'mode http'). Falling back to 'option tcplog'.
  [WARNING] 023/190810 (25554) : Server servers-http/test001.company.org is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
  [ALERT] 023/190810 (25554) : backend 'servers-http' has no server available!
  [WARNING] 023/190811 (25554) : Server servers-https/test001.company.org is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
  [ALERT] 023/190811 (25554) : backend 'servers-https' has no server available!

I'm not sure how server cannot be available, as the that server is the same server haproxy is deployed to; its the localhost, I'm just have the actual server name in the config file. That file is as follows:

global
  log 127.0.0.1   local0
  log 127.0.0.1   local1 notice
  #log loghost    local0 info
  maxconn 4096
  #debug
  #quiet
  user root
  group root

defaults
  log     global
  mode    http
  retries 3
  timeout client 50s
  timeout connect 5s
  timeout server 50s
  option dontlognull
  option httplog
  option redispatch
  balance  roundrobin

# Set up application listeners here.

listen admin
  bind 127.0.0.1:22002
  mode http
  stats uri /


frontend http
  maxconn 2000
  bind 0.0.0.0:4000
  default_backend servers-http

frontend https
  mode tcp
  maxconn 2000
  bind 0.0.0.0:4001
  default_backend servers-https


backend servers-http
  server test001.company.com <IP address here>:4002 weight 1 maxconn 100 check

backend servers-https
  mode tcp
  server test001.company.com <IP address here>:4003 weight 1 maxconn 100 check
  option ssl-hello-chk

I've also used netstat -nlp to make sure each port does not have anything running on it. I'm not sure what else I can check.

EDIT:

I opened another terminal just to check and confirmed that HAProxy is starting up and running on ports 4000 and 4001. However, the backend ports cannot be used. I've also confirmed that nothing is using these ports, using netstat -nlp | grep 4002 and netstat -nlp | grep 4003. I've also tried using 127.0.0.1 as the IP address instead of the actual IP address, but continue to get the same error.

SVill
  • 77
  • 3
  • 13

1 Answers1

1

Using 127.0.0.1 as "IP address here" in your config.

You need something listening on that 4002 and 4003 ports.

# netstat -nlp | grep 4002
tcp        0      0 0.0.0.0:4002            0.0.0.0:*               LISTEN      1564/python

For example, using the python basic HTTP server:

# python -m SimpleHTTPServer 4002
Serving HTTP on 0.0.0.0 port 4002 ...
127.0.0.1 - - [27/Jan/2020 22:55:34] "GET / HTTP/1.1" 200 -

You can see the request from:

$ wget 127.0.0.1:4000
--2020-01-27 22:55:34--  http://127.0.0.1:4000/
Connecting to 127.0.0.1:4000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 354 [text/html]
Saving to: 'index.html'

index.html 100%[=========================================>]     354  --.-KB/s    in 0s      

2020-01-27 22:55:34 (12.3 MB/s) - 'index.html' saved [354/354]
saf
  • 171
  • 5
  • This is correct. I had a fundamental misunderstanding on how haproxy works, thinking that it would listen on the backend ports and that I had to modify applications on the backend to speak with it. Thank you. – SVill Jan 28 '20 at 15:32