haproxy基本了解

haproxy基本了解

haproxy是一个高性能的、开源的TCP/http负载均衡器和反向代理,用于分发网络流量到多个后端服务器。

工作原理

主要组件:
frontend前端组件
backend后端组件
listen: 同时前端和后端功能
可选负载均衡算法:
roundrobin:轮询
leastcorn: 最少连接数
source: 基于源ip哈希
static-rr: 静态权重查询

基础配置

配置文件/etc/haproxy/haproxy.cfg

# /etc/haproxy/haproxy.cfg

global
    daemon
    maxconn 256

defaults
    mode http
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms

frontend http_front
    bind *:6443
    default_backend http_back

backend http_back
    balance roundrobin
    server server1 192.168.1.10:6443 check
    server server2 192.168.1.11:6443 check
posted @ 2025-12-22 00:24  LemHou  阅读(7)  评论(0)    收藏  举报