I am attempting to learn how to forward http traffic with HA Proxy. To get started I thought I would use Docker and have come stuck.
The forwarding traffic im attempting to do looks like this
ha-proxy container port 81
>>> forward to
nginx container port 8088
When I load the ha proxy container from my browser with the url http://localhost:81/ The error message I get is
503 Service Unavailable No server is available to handle this request.
My setup looks like the following.
nginx - container
When I load http://localhost:8088/ I get the correct Welcome to nginx!
home page.
Docker command im using for that is. Im using --net=host
so it binds it the host network.
docker run --name myapp-backend -p 8088:80 -d --net=host nginx:1.15.0-alpine
Ha Proxy
Dockerfile
FROM haproxy:alpine
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
haproxy.cfg
global
log 127.0.0.1 local0
maxconn 4096
defaults
log global
mode http
option httplog
option dontlognull
retries 3
redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
frontend http-in
bind *:81
acl myapp-frontend hdr(host) -i localhost
use_backend myapp-backend if myapp-frontend
backend myapp-backend
balance roundrobin
option http-server-close
server myapp-server-1 localhost:8088 check
Starting HA Proxy
docker build -t rob-haproxy .
docker run --name ha-proxy -p 81:81 --net=host -d rob-haproxy
My thinking is that I have something wrong with the ha proxy config file haproxy.cfg. Any advice much appreciated.