Answer the question
In order to leave comments, you need to log in
Why is HaProxy returning a 503 Service Unavailable error?
Hello.
There is a host with HAProxy
that accepts incoming http/https traffic
192.168.1.12
and distributes it to 2 backends
10.0.1.12
10.0.1.13
using HAProxy version 1.8
config
---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
# to have these messages end up in /var/opt/rh/rh-haproxy18/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/opt/rh/rh-haproxy18/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/opt/rh/rh-haproxy18/log/haproxy.log
#
log 127.0.0.1 local2
chroot /var/opt/rh/rh-haproxy18/lib/haproxy
pidfile /var/run/rh-haproxy18-haproxy.pid
maxconn 20000
daemon
#nbproc 1
#nbthread 3
#cpu-map auto:1/1-3 0-2
# turn on stats unix socket
stats socket /var/opt/rh/rh-haproxy18/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 15s
timeout server 15s
timeout http-keep-alive 5s
timeout check 3s
maxconn 20001
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend http_frontend
bind *:80
default_backend http_backend
backend http_backend
mode http
server server1 10.0.1.12:8081 check
server server1 10.0.1.13:8081 check
# systemctl restart rh-haproxy18-haproxy.service && systemctl status rh-haproxy18-haproxy.service
● rh-haproxy18-haproxy.service - HAProxy Load Balancer
Loaded: loaded (/usr/lib/systemd/system/rh-haproxy18-haproxy.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2019-09-18 19:43:14 MSK; 15h ago
Process: 53539 ExecStartPre=/opt/rh/rh-haproxy18/root/usr/sbin/haproxy -f $CONFIG -c -q (code=exited, status=0/SUCCESS)
Main PID: 53541 (haproxy)
CGroup: /system.slice/rh-haproxy18-haproxy.service
├─53541 /opt/rh/rh-haproxy18/root/usr/sbin/haproxy -Ws -f /etc/opt/rh/rh-haproxy18/haproxy/haproxy.cfg -p /run/rh-haproxy18-haproxy.pid
└─53543 /opt/rh/rh-haproxy18/root/usr/sbin/haproxy -Ws -f /etc/opt/rh/rh-haproxy18/haproxy/haproxy.cfg -p /run/rh-haproxy18-haproxy.pid
# ps aux | grep haproxy
root 53541 0.0 0.0 77636 3632 ? Ss Sep18 0:00 /opt/rh/rh-haproxy18/root/usr/sbin/haproxy -Ws -f /etc/opt/rh/rh-haproxy18/haproxy/haproxy.cfg -p /run/rh-haproxy18-haproxy.pid
root 53543 0.0 0.0 80776 3736 ? Ss Sep18 0:00 /opt/rh/rh-haproxy18/root/usr/sbin/haproxy -Ws -f /etc/opt/rh/rh-haproxy18/haproxy/haproxy.cfg -p /run/rh-haproxy18-haproxy.pid
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 54542/haproxy
# curl http://localhost
<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>
# curl -iv 10.0.1.12:8081
# curl -iv 10.0.1.13:8081
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question