Q:

Haproxy always giving 503 Service Unavailable

I've installed Haproxy 1.8 on a Kubernetes Container.
Whenever I make any request to /test, I always get 503 Service Unavailable response. I want to return the stats page when I get a request to /test
Following is my configuration file:
/etc/haproxy/haproxy.cfg:
global
        daemon
        maxconn 256

defaults
        mode http
        timeout connect 15000ms
        timeout client 150000ms
        timeout server 150000ms

frontend stats
        bind *:8404
        mode http
        stats enable
        stats uri /stats
        stats refresh 10s

frontend http-in
        bind *:8083
        default_backend servers
        acl ar1 path -i -m sub /test
        use_backend servers if ar1

backend servers
        mode http
        server server1 10.1.0.46:8404/stats maxconn 32
        # 10.1.0.46 is my container IP

I can access the /stats page using:
curl -ik http://10.1.0.46:8404/stats

But when I do:
curl -ik http://10.1.0.46:8083/test

I always get following response:
HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Content-Type: text/html

<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>

I started haproxy using:
/etc/init.d/haproxy restart

and then subsequently restart it using:
haproxy -f haproxy.cfg -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid) 

Following is the output of netstat -anlp:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:5000            0.0.0.0:*               LISTEN      54/python3.5
tcp        0      0 0.0.0.0:8083            0.0.0.0:*               LISTEN      802/haproxy
tcp        0      0 0.0.0.0:8404            0.0.0.0:*               LISTEN      802/haproxy
tcp        0      0 10.1.0.46:8404          10.0.15.225:20647       TIME_WAIT   -
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name    Path

Following is the output of ps -eaf:
UID          PID    PPID  C STIME TTY          TIME CMD
root           1       0  0 Jul22 ?        00:00:00 /bin/sh -c /bin/bash -x startup_script.sh
root           6       1  0 Jul22 ?        00:00:00 /bin/bash -x startup_script.sh
root          54       6  0 Jul22 ?        00:00:09 /usr/local/bin/python3.5 /usr/local/bin/gunicorn --bind 0.0.0.0:5000 runner:app?
root          57      54  0 Jul22 ?        00:02:50 /usr/local/bin/python3.5 /usr/local/bin/gunicorn --bind 0.0.0.0:5000 runner:app?
root          61       0  0 Jul22 pts/0    00:00:00 bash
root         739       0  0 07:02 pts/1    00:00:00 bash
root         802       1  0 08:09 ?        00:00:00 haproxy -f haproxy.cfg -p /var/run/haproxy.pid -sf 793
root         804     739  0 08:10 pts/1    00:00:00 ps -eaf

Why could I be getting 503 unavailable always?

A:

Why do you use HAProxy 1.8 when a 2.2.x already exists?
You will need to adopt the path in the backend which can't be set on the server level.
backend servers
  mode http
  http-request set-path /stats
  server server1 10.1.0.46:8404 maxconn 32
  # 10.1.0.46 is my container IP

