【发布时间】:2021-11-02 13:56:29
【问题描述】:
我正在尝试使用单个复制服务部署一个由三个主机节点组成的 Docker Swarm,并在其前面放置一个 HAProxy。我希望客户端能够通过 SSL 连接。
我的docker-compose.yml:
version: '3.9'
services:
proxy:
image: haproxy
ports:
- 443:8080
volumes:
- haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
deploy:
placement:
constraints: [node.role == manager]
networks:
- servers-network
node-server:
image: glusk/hackathon-2021:latest
ports:
- 8080:8080
command: npm run server
deploy:
mode: replicated
replicas: 2
networks:
- servers-network
networks:
servers-network:
driver: overlay
我的haproxy.cfg(基于official example):
# Simple configuration for an HTTP proxy listening on port 80 on all
# interfaces and forwarding requests to a single backend "servers" with a
# single server "server1" listening on 127.0.0.1:8000
global
daemon
maxconn 256
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:80
default_backend servers
backend servers
server server1 127.0.0.1:8000 maxconn 32
我的主机是 Lightsail VPS Ubuntu 实例并共享同一个专用网络。
node-service 在其自己的容器中运行每个 https 服务器任务:0.0.0.0:8080。
我目前尝试完成这项工作的方法是将ssh 放入 manager 节点(它也有一个静态和公共 IP),从上面复制我的配置文件,然后运行:
docker stack deploy --compose-file=docker-compose.yml hackathon-2021
但它不起作用。
【问题讨论】:
-
找到一个有用的链接:haproxy.com/blog/…
标签: docker docker-compose docker-swarm haproxy