New Install 503 unavailable

First time install of haproxy 1.8.23-3 on a centos 8.2 box

I have found many examples for configuration files, varying slightly but am getting a service unavailable 503 when i try to access the shared ip

I will eventually have 2 haproxy and 2 web servers (port 80) but am trying to get just one working now.

Below is my configuration

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    log         127.0.0.1 local2     #Log configuration

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy             #Haproxy running under user and group "haproxy"
    group       haproxy
    daemon

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

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
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

#---------------------------------------------------------------------
#HAProxy Monitoring Config
#---------------------------------------------------------------------
#bind haproxy3-monitoring *:8080                #Haproxy Monitoring run on port 8080
#    mode http
#    option forwardfor
#    option httpclose
#    stats enable
#    stats show-legends
#    stats refresh 5s
#    stats uri /stats                             #URL for HAProxy monitoring
#    stats realm Haproxy\ Statistics
#    stats auth howtoforge:howtoforge            #User and Password for login to the monitoring dashboard
#    stats admin if TRUE
#    default_backend app-main                    #This is optionally for monitoring backend

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    log         127.0.0.1 local2     #Log configuration

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy             #Haproxy running under user and group "haproxy"
    group       haproxy
    daemon

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

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
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

#---------------------------------------------------------------------
#HAProxy Monitoring Config
#---------------------------------------------------------------------
#bind haproxy3-monitoring *:8080                #Haproxy Monitoring run on port 8080
#    mode http
#    option forwardfor
#    option httpclose
#    stats enable
#    stats show-legends
#    stats refresh 5s
#    stats uri /stats                             #URL for HAProxy monitoring
#    stats realm Haproxy\ Statistics
#    stats auth howtoforge:howtoforge            #User and Password for login to the monitoring dashboard
#    stats admin if TRUE
#    default_backend app-main                    #This is optionally for monitoring backend


#---------------------------------------------------------------------
# FrontEnd Configuration
#---------------------------------------------------------------------
frontend main
    bind *:80
    option http-server-close
    option forwardfor
    default_backend app-main

#---------------------------------------------------------------------
# BackEnd roundrobin as balance algorithm
#---------------------------------------------------------------------
backend app-main
    balance roundrobin                                     #Balance algorithm
    server webtest1 10.60.4.40:80 #check                 #Nginx1
    server webtest2 10.60.4.41:80 #check                 #Nginx2

Shared ip is 10.60.4.50 and when i try to go to that ip i see the error message.

Any help is appreciated

additional information, if i uncommecnt the check in the backend instead of 503 unavailable i get 400 bad request

I’m assuming that the 400 Bad request comes from your backend server and is the reason why http health checks fails.

Now when healtch checks to all servers fail, the result is that no servers are actually considered available and therefor you’ll see the 503 error.

From the haproxy box, try running curl -vv http://10.60.4.40:80 and post the output here, in code tags ( use the </> symbol in the format settings of this forum).

Also please do check nginx servers logs, when you see the 400 Bad request answers.