主要是测试下基于haproxy 代理minio ,比较简单
环境准备
- docker-compose 文件
version: '3'
services:
minio:
image: minio/minio
ports:
- "9000:9000"
- "19001:19001"
environment:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
command: server --console-address :19001 --quiet /data
haproxy:
image: haproxytech/haproxy-debian:2.6.6
ports:
- 5000:5000
- 9001:9001
volumes:
- "./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg"
- haproxy.cfg
global
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
resolvers mydns
nameserver dns1 127.0.0.11:53
resolve_retries 3
timeout retry 1s
hold other 30s
hold refused 30s
hold nx 30s
hold timeout 30s
hold valid 10s
listen stats
bind *:9001
mode http
stats enable
stats uri /m
frontend main
bind *:5000
option forwardfor
http-request add-header X-Forwarded-Host %[req.hdr(host)]
http-request add-header X-Forwarded-Server %[req.hdr(host)]
http-request add-header X-Forwarded-Port %[dst_port]
default_backend app
backend app
server s31 minio:9000
效果
使用mc 工具
- 配置mc
mc config host add locals3appv2 http://127.0.0.1:5000 minio minio123
- 上传文件&生成下载地址
mc share download locals3appv2/demoapp/soapui-settings.xml
说明
以上是一个简单的测试,实际上基于haproxy 的入口层玩法,在好多公司也是比较常见的,毕竟haproxy 能力还是很强大的,性能也很不错,自身提供的负载均衡算法以及主动健康检查,acl能力都是很不错的
参考资料
http://docs.haproxy.org/2.6/configuration.html#5.3
https://www.haproxy.com/blog/dns-service-discovery-haproxy/