HAProxy 是一款高性能的 TCP 代理和 HTTP 反向代理服务器,支持 SSL 终止与卸载、TCP/HTTP 协议规范化、流量调节、缓存以及 DDoS ***防护等功能。Bitnami HAProxy 镜像经过精心构建和主动维护,提供预配置的容器化部署方案,适用于 Kubernetes 集群环境,可快速部署用于生产工作负载的 HAProxy 实例。
自 2025 年 8 月 28 日起,Bitnami 将升级其公共镜像仓库,推出 Bitnami Secure Images 计划,旨在提升容器镜像的安全性。变更详情如下:
latest 标签,用于开发目的)2.50.0、10.6)将在两周内从 docker.io/bitnami 迁移至 docker.io/bitnamilegacy 仓库,且不再接收更新bitnamilegacy 仓库中的历史镜像(无更新)或 bitnami 仓库的 latest 标签硬化镜像详情参见 Bitnami Secure Images 公告
使用 Helm 安装 HAProxy 实例,指定发布名称 my-release:
consolehelm install my-release oci://registry-1.docker.io/bitnamicharts/haproxy
注意:若使用迁移后的历史镜像,需将仓库地址替换为
oci://registry-1.docker.io/bitnamilegacycharts/haproxy
HAProxy 核心通过 haproxy.cfg 文件配置,可通过 Helm 参数 configuration 注入自定义配置。示例如下(将 8080 端口请求转发至集群内 service1:8080 服务):
yamlconfiguration: | global log 127.0.0.1 local2 maxconn 4096 defaults mode http log global option httplog option dontlognull option http-server-close option forwardfor except 127.0.0.0/8 retries 3 timeout http-request 20s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m maxconn 3000 frontend fe_http bind *:8080 default_backend be_http backend be_http balance roundrobin server app1 service1:8080 check port 8080
根据自定义配置调整容器端口和服务暴露规则:
yaml# values.yaml 示例 containerPorts: - name: http containerPort: 8080 # 对应配置中 frontend 绑定的端口 service: ports: - name: http port: 80 # 外部访问端口 targetPort: http # 关联 containerPorts 中的名称
使用 bitnamilegacy 仓库的历史镜像启动 HAProxy 容器(需提前准备 haproxy.cfg 配置文件):
consoledocker run -d \ --name haproxy \ -p 80:8080 \ -v $(pwd)/haproxy.cfg:/opt/bitnami/haproxy/conf/haproxy.cfg \ docker.io/bitnamilegacy/haproxy:latest
yaml# docker-compose.yml version: '3' services: haproxy: image: docker.io/bitnamilegacy/haproxy:latest ports: - "80:8080" # 宿主机端口:容器内端口(需与 haproxy.cfg 中绑定端口一致) volumes: - ./haproxy.cfg:/opt/bitnami/haproxy/conf/haproxy.cfg:ro restart: unless-stopped
可通过环境变量调整容器运行时行为:
| 环境变量 | 描述 | 默认值 |
|---|---|---|
HAPROXY_UID | 运行 HAProxy 进程的用户 ID | 1001 |
HAPROXY_GID | 运行 HAProxy 进程的组 ID | 1001 |
HAPROXY_LOG_LEVEL | 日志级别(debug/info/warn) | info |
HAPROXY_CONFIG_FILE | 配置文件路径 | /opt/bitnami/haproxy/conf/haproxy.cfg |
通过 Helm 参数 resources 设置容器资源请求与限制:
yamlresources: requests: cpu: 100m memory: 128Mi limits: cpu: 500m memory: 256Mi
HAProxy 配置文件为无状态资源,备份时需保存 haproxy.cfg 及关联证书文件。Kubernetes 环境中可通过以下方式备份:
consolehelm get values my-release > haproxy-values.yaml
consolekubectl get configmap my-release-haproxy -o yaml > haproxy-configmap.yaml
| 参数名 | 描述 | 默认值 |
|---|---|---|
global.imageRegistry | 全局 Docker 镜像仓库地址 | "" |
global.imagePullSecrets | 镜像拉取密钥列表 | [] |
global.security.allowInsecureImages | 是否允许跳过镜像校验 | false |
global.compatibility.openshift.adaptSecurityContext | 是否适配 OpenShift 安全上下文(auto/force/disabled) | auto |
| 参数名 | 描述 | 默认值 |
|---|---|---|
nameOverride | 部分覆盖资源名称前缀 | "" |
fullnameOverride | 完全覆盖资源完整名称 | "" |
commonLabels | 附加到所有资源的标签 | {} |
clusterDomain | Kubernetes 集群域名 | cluster.local |
diagnosticMode.enabled | 启用诊断模式(禁用探针,覆盖启动命令) | false |
| 参数名 | 描述 | 默认值 |
|---|---|---|
service.type | Service 类型(ClusterIP/NodePort/Load***) | Load*** |
service.ports | 服务暴露端口列表(格式:[{name: "http", port: 80, targetPort: "http"}]) | [] |
ingress.enabled | 是否启用 Ingress 资源 | false |
ingress.hostname | Ingress 规则默认主机名 | haproxy.local |
networkPolicy.enabled | 是否创建 NetworkPolicy 资源 | true |
| 参数名 | 描述 | 默认值 |
|---|---|---|
image.registry | 镜像仓库地址 | docker.io |
image.repository | 镜像仓库路径 | bitnamilegacy/haproxy |
image.pullPolicy | 镜像拉取策略(Always/IfNotPresent) | IfNotPresent |
replicaCount | 部署副本数 | 1 |
configuration | 内联 HAProxy 配置内容(覆盖默认 haproxy.cfg) | "" |
2.50.0)仅保留在 bitnamilegacy 仓库,且不再更新haproxy.cfg 后需通过 haproxy -c -f haproxy.cfg 验证语法正确性,避免容器启动失败maxconn(最大连接数)、超时时间等参数,避免连接堆积或过早断开完整文档参见 Bitnami HAProxy Chart 仓库

来自真实用户的反馈,见证轩辕镜像的优质服务
免费版仅支持 Docker Hub 加速,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
免费版仅支持 docker.io;专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像加速服务
在 Docker Desktop 配置镜像加速
Docker Compose 项目配置加速
Kubernetes 集群配置 Containerd
在宝塔面板一键配置镜像加速
Synology 群晖 NAS 配置加速
飞牛 fnOS 系统配置镜像加速
极空间 NAS 系统配置加速服务
爱快 iKuai 路由系统配置加速
绿联 NAS 系统配置镜像加速
QNAP 威联通 NAS 配置加速
Podman 容器引擎配置加速
HPC 科学计算容器配置加速
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名加速
需要其他帮助?请查看我们的 常见问题 或 官方QQ群: 13763429