# Running HAProxy as Reverse proxy using container

**URL:** <https://discourse.haproxy.org/t/running-haproxy-as-reverse-proxy-using-container/6831>\
**Category:** Help!\
**Created:** [August 17, 2021, 6:55am UTC](https://discourse.haproxy.org/t/running-haproxy-as-reverse-proxy-using-container/6831 "2021-08-17T06:55:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mg78](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@mg78](https://discourse.haproxy.org/u/mg78)\
**Post date:** [August 17, 2021, 6:55am UTC](https://discourse.haproxy.org/t/running-haproxy-as-reverse-proxy-using-container/6831/1 "2021-08-17T06:55:40Z")

</div>

I have simple haproxy.cfg working on a VM.

> frontend main  
> mode http  
> bind :80  
> bind :443 ssl crt /etc/haproxy/certs/current/my.pem  
> http-request redirect scheme https unless { ssl\_fc }  
> default\_backend app

> frontend stagesvc-api  
> bind \*:8001-8005 ssl crt /etc/haproxy/certs/current/my.pem ssl crt /etc/haproxy/certs/current  
> mode http  
> acl acl\_stagesvc-api hdr(host) -i [stagesvc-api.kbing.com](http://stagesvc-api.kbing.com)  
> acl acl\_stagesvc-api hdr\_beg(host) -i [stagesvc-api.kbing.com](http://stagesvc-api.kbing.com):  
> use\_backend bk\_stagesvc-api if acl\_stagesvc-api

> backend bk\_stagesvc-api  
> acl forwarded\_proto hdr\_cnt(X-Forwarded-Proto) eq 0  
> acl forwarded\_port hdr\_cnt(X-Forwarded-Port) eq 0  
> http-request add-header X-Forwarded-Port %[dst\_port] if forwarded\_port  
> http-request add-header X-Forwarded-Proto https if { ssl\_fc } forwarded\_proto  
> mode http  
> server app2 [stagesvc-aus.kbing.com](http://stagesvc-aus.kbing.com): check port 8001

I would like to use HAProxy docker image instead and achieve same as above.

#ls haproxy/  
drwxr-xr-x 3 haproxy haproxy 21 Jul 26 17:21 certs  
-rwxr-xr-x 1 haproxy haproxy 6902 Aug 16 23:57 haproxy.cfg

#docker run -d --name haproxy-lb -p 80:80 -v $PWD/haproxy:/usr/local/etc/haproxy:ro haproxy:2.4.2

docker: Error response from daemon: driver failed programming external connectivity on endpoint haproxy-lb (06103ac6b845c6f9fcce50c76b35931756e69af5635f038c7220037fc0f10555): (iptables failed: iptables --wait -t filter -A DOCKER ! -i docker0 -o docker0 -p tcp -d 172.17.0.2 --dport 80 -j ACCEPT: iptables: No chain/target/match by that name.

Any help or pointers is appreciated!

---

<div class="post-metadata">

**Author:** ![rhada](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/rhada/32/585_2.png) [@rhada](https://discourse.haproxy.org/u/rhada)\
**Post date:** [August 19, 2021, 2:13pm UTC](https://discourse.haproxy.org/t/running-haproxy-as-reverse-proxy-using-container/6831/2 "2021-08-19T14:13:54Z")

</div>

Hello,

It looks like it’s more a Docker issue than a Haproxy issue. When you publish a port with Docker, an iptables rule is added to route the traffic to the published port. This part seems not working. Maybe try to restart your docker daemon or re install it.
