i’m trying to deploy a docker swarm of two host nodes and two host manager with a single replicated service and put an haproxy in front of it. i want the clients to be able to connect via port 80.
My docker-compose.yml
version: '3.8'
services:
haproxy:
image: haproxy:latest
ports:
- 81:80
volumes:
- ./haproxy.cfg:/etc/haproxy/haproxy.cfg:ro
networks:
- cluster
deploy:
placement:
constraints:
- node.role == manager
apache:
image: httpd
deploy:
replicas: 2
placement:
constraints: [node.role == worker]
ports:
- 80:80
networks:
- cluster
volumes:
- stack_myvol:/var/www/html/
networks:
cluster:
volumes:
stack_myvol:
My haproxy.cfg
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
frontend http-in
bind 172.20.120.131:81
default_backend apache-servers
backend apache-servers
#balance leastconn
balance roundrobin
server node1 172.20.120.4:80 check
server node2 172.20.120.5:80 check
The way I’m trying to make this work at the moment is to ssh into the manager node (which also has a static and public IP), copy over my configuration files from above, and run:
docker stack deploy -c docker-compose.yml apache-stack
url: 172.20.120.131:81
unable to connect
hamed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.