title: HA Proxy simple forwarding with Docker
body: <p>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.  </p>
  
  <p>The forwarding traffic im attempting to do looks like this</p>
  
  <pre><code>ha-proxy container port 81
  &gt;&gt;&gt; forward to
  nginx container port 8088
  </code></pre>
  
  <p>When I load the ha proxy container from my browser with the url <a href="http://localhost:81/" rel="nofollow noreferrer">http://localhost:81/</a>  The error message I get is </p>
  
  <p><code>503 Service Unavailable No server is available to handle this request.</code></p>
  
  <blockquote>
    <p>My setup looks like the following.  </p>
  </blockquote>
  
  <p><strong>nginx - container</strong></p>
  
  <p>When I load <a href="http://localhost:8088/" rel="nofollow noreferrer">http://localhost:8088/</a> I get the correct <code>Welcome to nginx!</code> home page.</p>
  
  <p>Docker command im using for that is.  Im using <code>--net=host</code> so it binds it the host network. </p>
  
  <pre><code>docker run --name myapp-backend -p 8088:80 -d --net=host  nginx:1.15.0-alpine  
  </code></pre>
  
  <p><strong>Ha Proxy</strong></p>
  
  <p><em>Dockerfile</em></p>
  
  <pre><code>FROM haproxy:alpine
  COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
  </code></pre>
  
  <p><em>haproxy.cfg</em></p>
  
  <pre><code>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
  </code></pre>
  
  <p><em>Starting HA Proxy</em></p>
  
  <pre><code>   docker build -t rob-haproxy .
     docker run --name ha-proxy -p 81:81  --net=host -d rob-haproxy
  </code></pre>
  
  <p>My thinking is that I have something wrong with the ha proxy config file haproxy.cfg. Any advice much appreciated.</p>