涛子 - 简单就是美

成单纯魁增,永继振国兴,克复宗清政,广开家必升

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  428 随笔 :: 0 文章 :: 19 评论 :: 22万 阅读

参考

https://devops.hc-yun.com/archives/18.html
https://www.cnblogs.com/dowi/p/10309418.html
https://www.haproxy.com/blog/haproxy-on-docker-swarm-load-balancing-and-dns-service-discovery
https://kubesphere.io/docs/v3.4/installing-on-linux/high-availability-configurations/set-up-ha-cluster-using-keepalived-haproxy
https://github.com/k911/haproxy-keepalived-docker
https://ratibor78.medium.com/ha-redis-clustering-from-scratch-ebc5e81d7a78

1. compose

# cat > haproxy.yml << EOF
version: '3.8'

services:
  haproxy01:
    image: bitnami/haproxy:2.9.4
    container_name: haproxy01
    hostname: haproxy01.local
    ports:
      - 29080:8080
      - 29443:9999
    volumes:
      - $PWD/haproxy.cfg:/bitnami/haproxy/conf/haproxy.cfg
    networks:
      haproxy-net:
        ipv4_address: 172.16.22.11
    #sysctls:
    #  net.ipv4.ip_unprivileged_port_start: 0

networks:
  haproxy-net:
    name: haproxy-net
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.16.22.0/24
          gateway: 172.16.22.1

# Reloading config (container_name)
# docker kill -s HUP haproxy01
EOF

2. config

# cat > haproxy.cfg << EOF
global
  log stdout format raw local0 info

defaults
  mode http
  timeout client 10s
  timeout connect 5s
  timeout server 10s
  timeout http-request 10s
  log global

frontend stats
  bind *:9999
  stats enable
  stats uri /
  stats refresh 30s

frontend myfrontend
  bind *:8080
  default_backend web

backend web
  server srv-1 10.132.127.8:8080 check
  server srv-2 192.168.2.12:8080 check
  server srv-3 192.168.2.13:8080 check
EOF
posted on   北京涛子  阅读(71)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
历史上的今天:
2018-02-02 签名&加密的区别
2015-02-02 linux单机限速工具
点击右上角即可分享
微信分享提示