使用haproxy 代理minio

主要是测试下基于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/

posted on   荣锋亮  阅读(571)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2021-10-30 dremio rbac 功能简单说明一
2021-10-30 dremio 19.0 几个扩展包说明
2021-10-30 dremio 实现类似官方create user sql 处理的思路
2021-10-30 dremio 19.0 创建用户bug说明
2019-10-30 使用viper 进行golang 应用的配置管理
2019-10-30 systemd socket activation golang demo
2018-10-30 SQL Support and Workarounds

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示