Docker Community Forums

Share and learn in the Docker community.

"No route to host" issue with deploying Haproxy and Apache with docker-compose

Hello,

I’m new to docker and for the last few days I’m trying to figure out how to make HAproxy and Apache (or Nginx) work together. My goal is to have HaProxy as a load-balancing server for 2 webservers. I was able to succesfuly build 3 containers with docker-compose but there seems to be an issue with connection between HaProxy and webserves. Not really sure what I’m missing.

I’m using this configuration:


I’m running it on Centos 8.

The issue:

[john@centos8a 12:21:02 haproxy_nginx]$ docker-compose up
Creating network "haproxy_nginx_default" with the default driver
Creating web1 ... done
Creating web2 ... done
Creating haproxy ... done
Attaching to web1, web2, haproxy
web1       | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.27.0.2. Set the 'ServerName' directive globally to suppress this message
web1       | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.27.0.2. Set the 'ServerName' directive globally to suppress this message
web1       | [Thu Jan 30 11:21:05.898867 2020] [mpm_event:notice] [pid 1:tid 140151592633472] AH00489: Apache/2.4.41 (Unix) configured -- resuming normal operations
web1       | [Thu Jan 30 11:21:05.898997 2020] [core:notice] [pid 1:tid 140151592633472] AH00094: Command line: 'httpd -D FOREGROUND'
web2       | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.27.0.3. Set the 'ServerName' directive globally to suppress this message
web2       | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.27.0.3. Set the 'ServerName' directive globally to suppress this message
web2       | [Thu Jan 30 11:21:06.293907 2020] [mpm_event:notice] [pid 1:tid 139994078790784] AH00489: Apache/2.4.41 (Unix) configured -- resuming normal operations
web2       | [Thu Jan 30 11:21:06.294215 2020] [core:notice] [pid 1:tid 139994078790784] AH00094: Command line: 'httpd -D FOREGROUND'
haproxy    | [NOTICE] 029/112106 (1) : New worker #1 (6) forked
haproxy    | [WARNING] 029/112107 (6) : Server http-out/web1 is DOWN, reason: Layer4 connection problem, info: "No route to host", check duration: 1047ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
haproxy    | [WARNING] 029/112108 (6) : Server http-out/web2 is DOWN, reason: Layer4 connection problem, info: "No route to host", check duration: 1058ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
haproxy    | [ALERT] 029/112108 (6) : backend 'http-out' has no server available!

Someone could help me here with this, please?