Chemmy's Blog

chengming0916@outlook.com

本文档整合了多种SOCKS5代理服务器的搭建方法,包括SS5DanteSquidMicrosocks,旨在为不同需求和场景提供选择。

一、 方案概览与选择

方案 特点 适用场景 复杂度
SS5 经典SOCKS5服务器,功能全面,支持用户认证。 需要稳定、功能完整的SOCKS5代理。 中等
Dante 轻量级、高性能的SOCKS4/5服务器,配置灵活。 对性能和资源占用有要求的生产环境。 中等
Squid 功能强大的HTTP/HTTPS缓存代理,也支持SOCKS。 主要需求为Web缓存,同时需要SOCKS功能。 较高
Microsocks 极致轻量、内存占用极小的SOCKS5服务器。 资源受限的VPS、临时或简单代理需求。

环境建议:CentOS 7.x, Debian 7+, Ubuntu 14.04+。避免使用CentOS 8.x(兼容性问题)。确保服务器防火墙/安全组已开放代理端口。


二、 SS5 搭建方案

SS5是一个功能完整的SOCKS5代理服务器。

1. 安装依赖与源码

1
2
3
4
5
6
7
yum -y install gcc gcc-c++ automake make pam-devel openldap-devel cyrus-sasl-devel openssl openssl-devel
wget http://nchc.dl.sourceforge.net/project/ss5/ss5/3.8.9-8/ss5-3.8.9-8.tar.gz
tar -zxvf ss5-3.8.9-8.tar.gz
cd ss5-3.8.9/
./configure
make
make install

2. 服务注册与自启

1
2
3
chmod +x /etc/init.d/ss5
chkconfig --add ss5
chkconfig ss5 on

3. 核心配置

  • 认证配置 (/etc/opt/ss5/ss5.conf):
    1
    2
    auth    0.0.0.0/0       -       u
    permit u 0.0.0.0/0 - 0.0.0.0/0 - - - - -
  • 用户密码 (/etc/opt/ss5/ss5.passwd):
    1
    username password
  • 修改端口 (/etc/sysconfig/ss5):
    1
    SS5_OPTS=" -u root -b 0.0.0.0:8899"

4. 启动与测试

1
service ss5 start  # 或 restart

使用Proxifier等客户端工具,配置代理服务器地址和端口进行连接测试。


三、 Dante 搭建方案

Dante是一个高效、配置灵活的SOCKS服务器。

1. 安装 (CentOS 7)

1
2
rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm
yum --enablerepo=gf-plus install dante-server -y

2. 基础配置 (/etc/sockd.conf)
以下是一个允许所有连接(无认证)的简单配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
errorlog: /var/log/sockd.errlog
logoutput: /var/log/sockd.log

internal: eth0 port = 1080 # 监听端口
external: eth0

method: none # 无认证

client pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
}

socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
}

注意:需创建日志目录 mkdir /var/run/sockd

3. 启动与管理

1
2
systemctl start sockd
systemctl enable sockd

4. 高级配置

  • 用户认证:将 method: none 改为 method: username,并使用系统用户登录。
  • 访问控制:在 client passsocks pass 块中,通过 from: / to: 字段精细控制源IP和目标地址。

四、 Squid 搭建方案 (支持正向/透明代理)

Squid主要用作HTTP代理,但也可配置为SOCKS代理,并支持强大的访问控制。

1. 安装

1
2
3
sudo apt-get install squid -y  # Ubuntu/Debian
# 或安装支持SSL的版本以启用HTTPS透明代理
sudo apt-get install squid-openssl -y

2. 基础正向代理配置

  • 编辑 /etc/squid/squid.conf,添加允许的客户端网段:
    1
    acl localnet src 172.28.0.0/16
  • /etc/squid/conf.d/debian.conf 中取消注释:
    1
    http_access allow localnet
  • 重启服务:sudo service squid restart
  • 客户端在浏览器或系统设置中配置HTTP代理为Squid服务器IP:3128。

3. 强大的访问控制示例 (在squid.conf中配置)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 1. 禁止特定IP
acl badhost src 172.28.18.7
http_access deny badhost

# 2. 禁止特定时间段
acl worktime time MTWHF 17:00-18:00
http_access deny worktime

# 3. 禁止特定域名
acl baddomain dstdomain .taobao.com .pinduoduo.com
http_access deny baddomain

# 4. 禁止访问所有IP地址(防域名绕过)
acl ipurl url_regex ^http://[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/
http_access deny ipurl

4. 透明代理配置 (需双网卡)

  • 配置Squid:在 squid.conf 中添加拦截端口。
    1
    2
    http_port 3129 intercept  # HTTP透明代理
    https_port 3130 ssl-bump cert=/etc/squid/certs/myCA.pem transparent # HTTPS透明代理
  • 生成自签名CA证书 (用于HTTPS解密):
    1
    openssl req -new -newkey rsa:4096 -sha256 -days 3650 -nodes -x509 -keyout myCA.pem -out myCA.pem
  • 配置iptables规则,将客户端的80/443流量重定向到Squid。
  • 客户端需将网关和DNS指向Squid服务器内网IP,并导入生成的CA证书。

五、 Microsocks 搭建方案 (极致轻量)

适用于内存资源紧张的VPS。

1. 安装

  • Debian/Ubuntu新版本sudo apt install microsocks
  • 旧版本或从源码安装
    1
    2
    3
    4
    wget http://ftp.barfooze.de/pub/sabotage/tarballs/microsocks-1.0.4.tar.xz
    tar -Jxf microsocks-1.0.4.tar.xz
    cd microsocks-*/
    make && sudo make install

2. 直接运行

1
microsocks -1 -u USERNAME -P PASSWORD
  • -1: 认证一次后IP加入白名单。
  • -u / -P: 用户名和密码。
  • 默认监听 0.0.0.0:1080

3. 配置为Systemd服务 (推荐)

  • 创建服务文件 /etc/systemd/system/microsocks.service
  • 创建配置文件 /etc/microsocks.conf,定义 MICROSOCKS_LOGINMICROSOCKS_PASSW
  • 启用服务:sudo systemctl enable --now microsocks

六、 客户端连接与测试

  1. **命令行测试 (Linux/Mac)**:
    1
    curl --socks5 USER:PASS@SERVER_IP:PORT https://www.google.com/
  2. 浏览器设置:在网络设置中手动配置SOCKS5代理。
  3. 专业工具:使用 Proxifier (Windows/macOS) 或 Proxy SwitchyOmega (浏览器插件) 进行全局或按规则代理。
  4. **环境变量 (Linux)**:
    1
    2
    export http_proxy=socks5://SERVER_IP:PORT
    export https_proxy=socks5://SERVER_IP:PORT

七、 故障排查

  1. 连接失败
    • 检查服务器防火墙/安全组规则是否放行代理端口。
    • 确认代理服务正在运行 (systemctl status xxx)。
    • 查看服务日志 (journalctl -xe, /var/log/xxx.log)。
  2. 认证失败:检查配置文件的用户名/密码部分,确保无拼写错误。
  3. Squid HTTPS代理失败:确保使用了 squid-openssl,正确生成并配置了CA证书,且客户端已导入该证书。

八、 总结与建议

  • 追求轻量与简单:首选 Microsocks
  • 需要稳定完整的SOCKS5服务:选择 SS5Dante
  • 主要需求是Web缓存和复杂的内容过滤:选择 Squid
  • 生产环境:务必配置用户认证和基于IP的**访问控制列表(ACL)**,并定期检查日志。

请根据您的具体需求(性能、功能、易用性、资源占用)选择最合适的方案进行部署。

一、准备工作

1.1 获取服务器

本文使用阿里云 ECS 服务器(香港节点,CentOS 7.9 64位)进行演示。学生用户可通过阿里云学生计划免费领取服务器。

重要信息记录

  • 公网 IP 地址:在服务器控制台查看并记录(后续配置需要)
  • 操作系统:CentOS 7.9 64位

1.2 安装 Docker(如未安装)

1.2.1 更新系统并安装依赖

1
2
sudo yum update -y
sudo yum install -y yum-utils device-mapper-persistent-data lvm2

1.2.2 添加 Docker 官方仓库

1
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

1.2.3 安装 Docker

1
sudo yum install -y docker-ce docker-ce-cli containerd.io

1.2.4 启动并设置开机自启

1
2
sudo systemctl start docker
sudo systemctl enable docker

1.2.5 验证安装

1
2
3
4
5
# 查看 Docker 版本
docker --version

# 测试 Docker 运行
sudo docker run hello-world

验证成功标志:能看到 hello-world 镜像拉取成功并运行。


二、配置 VPN 服务器

2.1 创建配置目录

1
2
mkdir -p /vpn
cd /vpn

2.2 创建环境配置文件

创建并编辑 .env 文件:

1
2
3
nano /vpn/.env
# 或使用 vim
# vim /vpn/.env

2.3 配置文件内容

将以下配置粘贴到 .env 文件中,根据实际情况修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# IPsec 预共享密钥(重要!)
VPN_IPSEC_PSK=AKIDkQD7!

# 主 VPN 账号和密码
VPN_USER=test
VPN_PASSWORD=vpn1234

# 服务器公网 IP(必须修改为你的服务器 IP)
VPN_PUBLIC_IP=36.111.xxx.xxx

# 额外 VPN 用户(用户名用空格分隔)
VPN_ADDL_USERS=vpn1 vpn2

# 对应额外用户的密码(顺序与用户名对应)
VPN_ADDL_PASSWORDS=vpn11234 pass21234

# DNS 服务器配置
VPN_DNS_SRV1=8.8.8.8
VPN_DNS_SRV2=114.114.114.114

配置说明

  • VPN_PUBLIC_IP:必须替换为你的服务器公网 IP
  • VPN_IPSEC_PSK:建议使用强密码,包含大小写字母、数字和特殊字符
  • 多个用户配置:确保用户名和密码顺序对应

三、部署 VPN 容器

3.1 首次运行容器

1
2
3
4
5
6
7
8
docker run \
--name ipsec-vpn-server \
--env-file /vpn/.env \
--restart=always \
-p 500:500/udp \
-p 4500:4500/udp \
-v /lib/modules:/lib/modules:ro \
-d hwdsl2/ipsec-vpn-server

3.2 处理特权模式错误

如果出现错误提示需要特权模式,按以下步骤操作:

停止并删除现有容器

1
2
docker stop ipsec-vpn-server
docker rm ipsec-vpn-server

重新以特权模式运行

1
2
3
4
5
6
7
8
9
docker run \
--name ipsec-vpn-server \
--env-file /vpn/.env \
--restart=always \
--privileged \
-p 500:500/udp \
-p 4500:4500/udp \
-v /lib/modules:/lib/modules:ro \
-d hwdsl2/ipsec-vpn-server

3.3 检查容器状态

1
2
3
4
5
# 查看容器运行状态
docker ps

# 查看容器日志
docker logs ipsec-vpn-server

成功标志:日志中显示 IPsec VPN server started 或类似信息。


四、配置服务器防火墙

4.1 开放必要端口

VPN 服务需要以下 UDP 端口:

  • 500:ISAKMP(IKE 协商)
  • 4500:NAT-T(NAT 穿越)
  • 1701:L2TP(可选)

方法一:使用 iptables(命令行)

1
2
3
4
5
6
7
8
9
10
11
# 开放 UDP 500 端口
sudo iptables -A INPUT -p udp --dport 500 -j ACCEPT

# 开放 UDP 4500 端口
sudo iptables -A INPUT -p udp --dport 4500 -j ACCEPT

# 开放 UDP 1701 端口(L2TP)
sudo iptables -A INPUT -p udp --dport 1701 -j ACCEPT

# 保存规则(CentOS 7)
sudo service iptables save

方法二:使用云控制台(推荐)

以阿里云为例:

  1. 登录阿里云控制台
  2. 进入 ECS 实例详情页
  3. 找到「安全组」配置
  4. 点击「配置规则」
  5. 手动添加以下入方向规则:
授权策略 协议类型 端口范围 授权对象 描述
允许 UDP 500/500 0.0.0.0/0 IPsec ISAKMP
允许 UDP 4500/4500 0.0.0.0/0 IPsec NAT-T
允许 UDP 1701/1701 0.0.0.0/0 L2TP(可选)

4.2 重启容器使配置生效

1
docker restart ipsec-vpn-server

五、Windows 客户端连接配置

5.1 创建 VPN 连接

  1. 打开「设置」→「网络和 Internet」→「VPN」
  2. 点击「添加 VPN 连接」
  3. 填写以下信息:
    • VPN 提供商:Windows(内置)
    • 连接名称:自定义(如 MyVPN)
    • 服务器名称或地址:你的服务器公网 IP
    • VPN 类型:使用预共享密钥的 L2TP/IPsec
    • 预共享密钥.env 文件中的 VPN_IPSEC_PSK
    • 登录信息的类型:用户名和密码
    • 用户名.env 文件中的 VPN_USER
    • 密码.env 文件中的 VPN_PASSWORD

5.2 修改注册表(解决连接问题)

以管理员身份打开 PowerShell 或命令提示符,执行:

1
REG ADD HKLM\SYSTEM\CurrentControlSet\Services\PolicyAgent /v AssumeUDPEncapsulationContextOnSendRule /t REG_DWORD /d 0x2 /f

5.3 连接 VPN

  1. 执行上述命令后重启计算机
  2. 在系统托盘点击网络图标
  3. 选择创建的 VPN 连接
  4. 点击「连接」
  5. 输入用户名和密码(如已保存则自动连接)

六、Android 客户端连接配置

6.1 创建 VPN 连接

  1. 打开「设置」→「更多连接」→「VPN」
  2. 点击「添加 VPN」或「+」
  3. 填写以下信息:
    • 名称:自定义(如 MyVPN)
    • 类型:L2TP/IPSec PSK
    • 服务器地址:你的服务器公网 IP
    • L2TP 密钥:留空
    • IPSec 标识符:留空
    • IPSec 预共享密钥.env 文件中的 VPN_IPSEC_PSK
    • 用户名.env 文件中的 VPN_USER
    • 密码.env 文件中的 VPN_PASSWORD

6.2 保存并连接

  1. 点击「保存」
  2. 在 VPN 列表中选择刚创建的连接
  3. 点击「连接」

七、故障排除

7.1 常见问题及解决

问题1:容器启动失败,提示特权模式错误

解决:使用 --privileged 参数重新运行容器(见3.2节)

问题2:客户端连接超时

检查步骤

  1. 确认服务器公网 IP 正确
  2. 检查防火墙端口是否开放
  3. 验证容器是否正常运行
    1
    docker logs ipsec-vpn-server

问题3:Windows 连接错误 789

解决

  1. 确保已执行注册表修改命令(5.2节)
  2. 重启计算机
  3. 检查预共享密钥是否正确

问题4:能连接但无法上网

检查

  1. 确认 DNS 配置正确
  2. 检查服务器是否开启 IP 转发
    1
    echo 1 > /proc/sys/net/ipv4/ip_forward

7.2 查看连接状态

1
2
3
4
5
# 查看容器实时日志
docker logs -f ipsec-vpn-server

# 查看当前连接用户
docker exec ipsec-vpn-server ipsec status

八、安全建议

8.1 密码安全

  1. 使用强密码:预共享密钥和用户密码应包含大小写字母、数字和特殊字符
  2. 定期更换:建议每月更换一次密码
  3. 最小权限:只为必要用户创建 VPN 账号

8.2 服务器安全

  1. 限制访问:在安全组中限制源 IP(如只允许特定国家或 IP 段)
  2. 监控日志:定期检查 VPN 连接日志
  3. 更新维护:定期更新 Docker 镜像和系统

8.3 备份配置

1
2
3
4
5
# 备份 .env 配置文件
cp /vpn/.env /vpn/.env.backup.$(date +%Y%m%d)

# 导出容器配置
docker export ipsec-vpn-server > /vpn/vpn-backup.tar

九、总结

通过以上步骤,你已成功在 CentOS 7 服务器上使用 Docker 搭建了 IPsec VPN 服务器。关键要点:

  1. 环境准备:确保 Docker 正确安装
  2. 配置正确.env 文件中的公网 IP 必须准确
  3. 端口开放:确保 UDP 500 和 4500 端口对外开放
  4. 客户端配置:注意 Windows 需要修改注册表

优势

  • 使用 Docker 部署,简单快速
  • 支持多用户同时连接
  • 跨平台客户端支持(Windows、Android、iOS、macOS)
  • 配置易于备份和迁移

后续维护

  • 定期检查容器日志
  • 关注安全更新
  • 监控服务器资源使用情况

现在你可以安全地通过 VPN 访问你的服务器资源,或用于保护公共 Wi-Fi 下的网络通信。

项目风险通常体现在需求、技术、成本和进度四个方面。在IT项目开发中,常见的风险可归纳为以下九大类。

1. 需求风险

需求是项目的基石,其不确定性是主要风险来源。

  • 需求基准已定,但仍在持续变化。
  • 需求定义不清晰,后续的澄清工作会扩大项目范围。
  • 在项目过程中不断添加新的需求。
  • 产品定义中模糊的部分比预期消耗更多时间。
  • 客户在需求阶段参与不足。
  • 缺乏有效的需求变更管理流程。

2. 计划编制风险

计划不切实际或基于错误假设,将直接导致项目失控。

  • 计划仅依据客户或上级的口头指令制定,且指令本身可能存在矛盾。
  • 计划过于理想化(“最佳状态”),脱离现实,实为“期望状态”。
  • 计划依赖于特定的核心成员,而该成员可能无法到位或发挥作用。
  • 实际产品规模(代码行、功能点)远超预估。
  • 项目截止日期提前,但未相应缩减范围或增加资源。
  • 进入不熟悉的技术领域,导致设计和实现时间超出预期。

3. 组织与管理风险

低效的组织结构和决策流程会严重拖慢项目。

  • 仅由非技术人员(如管理层、市场人员)做技术决策,导致进度迟缓。
  • 项目团队结构不合理,降低了整体效率。
  • 管理层审批决策周期过长。
  • 项目预算中途被削减,打乱原有计划。
  • 管理层作出打击团队积极性的决定。
  • 缺乏必要的工作规范,导致失误和返工。
  • 依赖的非技术第三方(如法务、采购)工作延期。

4. 人员风险

人是项目成功的关键,人员问题会引发连锁反应。

  • 项目依赖的前置任务(如培训)未能按时完成。
  • 开发人员与管理者关系不佳,决策缓慢,影响全局。
  • 缺乏有效的激励措施,团队士气低落,生产力下降。
  • 成员需要额外时间适应不熟悉的工具和环境。
  • 项目后期加入新成员,产生培训与沟通成本,降低现有成员效率。
  • 团队内部发生冲突,导致沟通不畅、设计缺陷和返工。
  • 不称职的成员未被调离,影响整个团队的积极性。
  • 无法招募到项目急需的特定技能人才。

5. 开发环境风险

“工欲善其事,必先利其器”,糟糕的环境会阻碍开发。

  • 办公场所、硬件设施未能及时到位。
  • 设施不配套(如缺网络、电话)。
  • 工作环境拥挤、杂乱或破损。
  • 必要的开发工具未及时就绪。
  • 工具效果不如预期,需额外时间配置或更换。
  • 学习新工具的时间比预期长。

6. 客户风险

客户是项目的最终服务对象,其行为直接影响项目。

  • 客户对最终交付物不满意,要求返工或重做。
  • 客户的意见未被充分采纳,导致产品无法满足其真实需求。
  • 客户对方案、原型等的审核决策周期过长。
  • 客户未能参与关键阶段的评审,导致需求反复变更。
  • 客户回复问题(如需求澄清)的时间延迟。
  • 客户提供的组件质量差,导致额外的测试、集成和沟通工作。

7. 产品风险

产品本身的技术复杂度和依赖关系带来的挑战。

  • 为修正低质量产品,需要远超预期的测试和开发工作。
  • 开发了不必要的“镀金”功能,延长了工期。
  • 与现有系统兼容性要求苛刻,增加了工作量。
  • 需要与外部或不可控系统集成,带来未知工作量。
  • 在陌生或未经验证的软硬件环境中运行,产生意外问题。
  • 开发全新技术模块的时间远超预估。
  • 依赖尚未成熟的技术,会延长项目周期。

8. 设计与实现风险

将设计转化为代码过程中遇到的具体技术障碍。

  • 设计质量低劣,导致重复设计。
  • 现有代码库无法实现某些功能,必须开发新库或功能。
  • 采用的代码或第三方库质量低下,引发额外测试和修复工作。
  • 高估了新工具对效率的提升效果。
  • 各自开发的模块无法有效集成,需要重新设计。

9. 过程风险

项目所遵循的流程和管理方法本身存在的问题。

  • 过多的文书工作拖慢了项目进程。
  • 前期的质量保证流于形式,导致后期大量返工。
  • 流程过于松散(不遵循开发规范),导致沟通不畅、质量低下。
  • 流程过于僵化(教条式遵循规范),在无用流程上耗费时间。
  • 撰写管理报告占用了开发人员过多时间。
  • 风险管理疏忽,未能识别出重大风险。

总结:成功的IT项目管理,不仅在于技术实现,更在于对上述九大类风险的持续识别、评估和应对。建立规范流程、保持沟通顺畅、进行务实计划并预留缓冲,是 mitigating(缓解)这些风险的关键。

安装

1
2
3
4
5
6
7
8
helm repo add traefik https://helm.traefik.io/traefik
helm repo update
helm upgrade traefik traefik/traefik \
--install --create-namespace \
--namespace=traefik

# 导出配置文件
helm show values traefik/traefik > traefik-values.yaml

修改配置

traefik-values.yaml

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
# Default values for Traefik

# This is a YAML-formatted file.

# Declare variables to be passed into templates



image:  # @schema additionalProperties: false

  # -- Traefik image host registry

  registry: docker.io

  # -- Traefik image repository

  repository: traefik

  # -- defaults to appVersion

  tag:  # @schema type:[string, null]

  # -- Traefik image pull policy

  pullPolicy: IfNotPresent



# -- Add additional label to all resources

commonLabels: {}



deployment:

  # -- Enable deployment

  enabled: true

  # -- Deployment or DaemonSet

  kind: Deployment

  # -- Number of pods of the deployment (only applies when kind == Deployment)

  replicas: 1

  # -- Number of old history to retain to allow rollback (If not set, default Kubernetes value is set to 10)

  revisionHistoryLimit:  # @schema type:[integer, null];minimum:0

  # -- Amount of time (in seconds) before Kubernetes will send the SIGKILL signal if Traefik does not shut down

  terminationGracePeriodSeconds: 60

  # -- The minimum number of seconds Traefik needs to be up and running before the DaemonSet/Deployment controller considers it available

  minReadySeconds: 0

  ## -- Override the liveness/readiness port. This is useful to integrate traefik

  ## with an external Load Balancer that performs healthchecks.

  ## Default: ports.traefik.port

  healthchecksPort:  # @schema type:[integer, null];minimum:0

  ## -- Override the liveness/readiness host. Useful for getting ping to respond on non-default entryPoint.

  ## Default: ports.traefik.hostIP if set, otherwise Pod IP

  healthchecksHost: ""

  ## -- Override the liveness/readiness scheme. Useful for getting ping to

  ## respond on websecure entryPoint.

  healthchecksScheme:   # @schema enum:[HTTP, HTTPS, null]; type:[string, null]; default: HTTP

  ## -- Override the readiness path.

  ## Default: /ping

  readinessPath: ""

  # -- Override the liveness path.

  # Default: /ping

  livenessPath: ""

  # -- Additional deployment annotations (e.g. for jaeger-operator sidecar injection)

  annotations: {}

  # -- Additional deployment labels (e.g. for filtering deployment by custom labels)

  labels: {}

  # -- Additional pod annotations (e.g. for mesh injection or prometheus scraping)

  # It supports templating. One can set it with values like traefik/name: '{{ template "traefik.name" . }}'

  podAnnotations: {}

  # -- Additional Pod labels (e.g. for filtering Pod by custom labels)

  podLabels: {}

  # -- Additional containers (e.g. for metric offloading sidecars)

  additionalContainers: []

  # https://docs.datadoghq.com/developers/dogstatsd/unix_socket/?tab=host

  # - name: socat-proxy

  #   image: alpine/socat:1.0.5

  #   args: ["-s", "-u", "udp-recv:8125", "unix-sendto:/socket/socket"]

  #   volumeMounts:

  #     - name: dsdsocket

  #       mountPath: /socket

  # -- Additional volumes available for use with initContainers and additionalContainers

  additionalVolumes: []

  # - name: dsdsocket

  #   hostPath:

  #     path: /var/run/statsd-exporter

  # -- Additional initContainers (e.g. for setting file permission as shown below)

  initContainers: []

  # The "volume-permissions" init container is required if you run into permission issues.

  # Related issue: https://github.com/traefik/traefik-helm-chart/issues/396

  # - name: volume-permissions

  #   image: busybox:latest

  #   command: ["sh", "-c", "touch /data/acme.json; chmod -v 600 /data/acme.json"]

  #   volumeMounts:

  #     - name: data

  #       mountPath: /data

  # -- Use process namespace sharing

  shareProcessNamespace: false

  # -- Custom pod DNS policy. Apply if `hostNetwork: true`

  dnsPolicy: ""

  # -- Custom pod [DNS config](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#poddnsconfig-v1-core)

  dnsConfig: {}

  # -- Custom [host aliases](https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/)

  hostAliases: []

  # -- Pull secret for fetching traefik container image

  imagePullSecrets: []

  # -- Pod lifecycle actions

  lifecycle: {}

  # preStop:

  #   exec:

  #     command: ["/bin/sh", "-c", "sleep 40"]

  # postStart:

  #   httpGet:

  #     path: /ping

  #     port: 9000

  #     host: localhost

  #     scheme: HTTP

  # -- Set a runtimeClassName on pod

  runtimeClassName: ""



# -- [Pod Disruption Budget](https://kubernetes.io/docs/reference/kubernetes-api/policy-resources/pod-disruption-budget-v1/)

podDisruptionBudget:  # @schema additionalProperties: false

  enabled: false

  maxUnavailable:  # @schema type:[string, integer, null];minimum:0

  minAvailable:    # @schema type:[string, integer, null];minimum:0



# -- Create a default IngressClass for Traefik

ingressClass:  # @schema additionalProperties: false

  enabled: true

  isDefaultClass: true

  name: ""



core:  # @schema additionalProperties: false

  # -- Can be used to use globally v2 router syntax

  # See https://doc.traefik.io/traefik/v3.0/migration/v2-to-v3/#new-v3-syntax-notable-changes

  defaultRuleSyntax: ""



# Traefik experimental features

experimental:

  # -- Enable traefik experimental plugins

  plugins: {}

  # demo:

  #   moduleName: github.com/traefik/plugindemo

  #   version: v0.2.1

  kubernetesGateway:

    # -- Enable traefik experimental GatewayClass CRD

    enabled: false



gateway:

  # -- When providers.kubernetesGateway.enabled, deploy a default gateway

  enabled: true

  # -- Set a custom name to gateway

  name: ""

  # -- By default, Gateway is created in the same `Namespace` than Traefik.

  namespace: ""

  # -- Additional gateway annotations (e.g. for cert-manager.io/issuer)

  annotations: {}

  # -- Define listeners

  listeners:

    web:

      # -- Port is the network port. Multiple listeners may use the same port, subject to the Listener compatibility rules.

      # The port must match a port declared in ports section.

      port: 8000

      # -- Optional hostname. See [Hostname](https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.Hostname)

      hostname: ""

      # Specify expected protocol on this listener. See [ProtocolType](https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.ProtocolType)

      protocol: HTTP

      # -- Routes are restricted to namespace of the gateway [by default](https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.FromNamespaces

      namespacePolicy:  # @schema type:[string, null]

    # websecure listener is disabled by default because certificateRefs needs to be added,

    # or you may specify TLS protocol with Passthrough mode and add "--providers.kubernetesGateway.experimentalChannel=true" in additionalArguments section.

    # websecure:

    #   # -- Port is the network port. Multiple listeners may use the same port, subject to the Listener compatibility rules.

    #   # The port must match a port declared in ports section.

    #   port: 8443

    #   # -- Optional hostname. See [Hostname](https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.Hostname)

    #   hostname:

    #   # Specify expected protocol on this listener See [ProtocolType](https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.ProtocolType)

    #   protocol: HTTPS

    #   # -- Routes are restricted to namespace of the gateway [by default](https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.FromNamespaces)

    #   namespacePolicy:

    #   # -- Add certificates for TLS or HTTPS protocols. See [GatewayTLSConfig](https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io%2fv1.GatewayTLSConfig)

    #   certificateRefs:

    #   # -- TLS behavior for the TLS session initiated by the client. See [TLSModeType](https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.TLSModeType).

    #   mode:



gatewayClass:  # @schema additionalProperties: false

  # -- When providers.kubernetesGateway.enabled and gateway.enabled, deploy a default gatewayClass

  enabled: true

  # -- Set a custom name to GatewayClass

  name: ""

  # -- Additional gatewayClass labels (e.g. for filtering gateway objects by custom labels)

  labels: {}



ingressRoute:

  dashboard:

    # -- Create an IngressRoute for the dashboard

    enabled: true # 修改此处,启用dashboard

    # -- Additional ingressRoute annotations (e.g. for kubernetes.io/ingress.class)

    annotations: # 修改此处,添加配置
    ingress.kubernetes.io/ssl-redirect: "true"
    ingress.kubernetes.io/proxy-body-size: "0"
    kubernetes.io/ingress.class: "traefik"
    traefik.ingress.kubernetes.io/router.tls: "true"
    traefik.ingress.kubernetes.io/router.entrypoints: websecure

    # -- Additional ingressRoute labels (e.g. for filtering IngressRoute by custom labels)

    labels: {}

    # -- The router match rule used for the dashboard ingressRoute

    matchRule: PathPrefix(`/dashboard`) || PathPrefix(`/api`)

    # -- The internal service used for the dashboard ingressRoute

    services:

      - name: api@internal

        kind: TraefikService

    # -- Specify the allowed entrypoints to use for the dashboard ingress route, (e.g. traefik, web, websecure).

    # By default, it's using traefik entrypoint, which is not exposed.

    # /!\ Do not expose your dashboard without any protection over the internet /!\

    entryPoints: ["traefik"]

    # -- Additional ingressRoute middlewares (e.g. for authentication)

    middlewares: []

    # -- TLS options (e.g. secret containing certificate)

    tls: # 修改此处,配置证书,需要cert-manager
    enabled: true
    certSource: secret
    secret:
    secretName: "traefik-tls-secret"
   

  healthcheck:

    # -- Create an IngressRoute for the healthcheck probe

    enabled: false

    # -- Additional ingressRoute annotations (e.g. for kubernetes.io/ingress.class)

    annotations: {}

    # -- Additional ingressRoute labels (e.g. for filtering IngressRoute by custom labels)

    labels: {}

    # -- The router match rule used for the healthcheck ingressRoute

    matchRule: PathPrefix(`/ping`)

    # -- The internal service used for the healthcheck ingressRoute

    services:

      - name: ping@internal

        kind: TraefikService

    # -- Specify the allowed entrypoints to use for the healthcheck ingress route, (e.g. traefik, web, websecure).

    # By default, it's using traefik entrypoint, which is not exposed.

    entryPoints: ["traefik"]

    # -- Additional ingressRoute middlewares (e.g. for authentication)

    middlewares: []

    # -- TLS options (e.g. secret containing certificate)

    tls: {}



updateStrategy:  # @schema additionalProperties: false

  # -- Customize updateStrategy of Deployment or DaemonSet

  type: RollingUpdate

  rollingUpdate:

    maxUnavailable: 0  # @schema type:[integer, string, null]

    maxSurge: 1        # @schema type:[integer, string, null]



readinessProbe:  # @schema additionalProperties: false

  # -- The number of consecutive failures allowed before considering the probe as failed.

  failureThreshold: 1

  # -- The number of seconds to wait before starting the first probe.

  initialDelaySeconds: 2

  # -- The number of seconds to wait between consecutive probes.

  periodSeconds: 10

  # -- The minimum consecutive successes required to consider the probe successful.

  successThreshold: 1

  # -- The number of seconds to wait for a probe response before considering it as failed.

  timeoutSeconds: 2

livenessProbe:  # @schema additionalProperties: false

  # -- The number of consecutive failures allowed before considering the probe as failed.

  failureThreshold: 3

  # -- The number of seconds to wait before starting the first probe.

  initialDelaySeconds: 2

  # -- The number of seconds to wait between consecutive probes.

  periodSeconds: 10

  # -- The minimum consecutive successes required to consider the probe successful.

  successThreshold: 1

  # -- The number of seconds to wait for a probe response before considering it as failed.

  timeoutSeconds: 2



# -- Define [Startup Probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes)

startupProbe: {}



providers:  # @schema additionalProperties: false

  kubernetesCRD:

    # -- Load Kubernetes IngressRoute provider

    enabled: true

    # -- Allows IngressRoute to reference resources in namespace other than theirs

    allowCrossNamespace: false

    # -- Allows to reference ExternalName services in IngressRoute

    allowExternalNameServices: false

    # -- Allows to return 503 when there is no endpoints available

    allowEmptyServices: true

    # -- When the parameter is set, only resources containing an annotation with the same value are processed. Otherwise, resources missing the annotation, having an empty value, or the value traefik are processed. It will also set required annotation on Dashboard and Healthcheck IngressRoute when enabled.

    ingressClass: ""

    # labelSelector: environment=production,method=traefik

    # -- Array of namespaces to watch. If left empty, Traefik watches all namespaces.

    namespaces: []

    # -- Defines whether to use Native Kubernetes load-balancing mode by default.

    nativeLBByDefault: false



  kubernetesIngress:

    # -- Load Kubernetes Ingress provider

    enabled: true

    # -- Allows to reference ExternalName services in Ingress

    allowExternalNameServices: false

    # -- Allows to return 503 when there is no endpoints available

    allowEmptyServices: true

    # -- When ingressClass is set, only Ingresses containing an annotation with the same value are processed. Otherwise, Ingresses missing the annotation, having an empty value, or the value traefik are processed.

    ingressClass:  # @schema type:[string, null]

    # labelSelector: environment=production,method=traefik

    # -- Array of namespaces to watch. If left empty, Traefik watches all namespaces.

    namespaces: []

    # IP used for Kubernetes Ingress endpoints

    publishedService:

      enabled: false

      # Published Kubernetes Service to copy status from. Format: namespace/servicename

      # By default this Traefik service

      # pathOverride: ""

    # -- Defines whether to use Native Kubernetes load-balancing mode by default.

    nativeLBByDefault: false



  kubernetesGateway:

    # -- Enable Traefik Gateway provider for Gateway API

    enabled: false

    # -- Toggles support for the Experimental Channel resources (Gateway API release channels documentation).

    # This option currently enables support for TCPRoute and TLSRoute.

    experimentalChannel: false

    # -- Array of namespaces to watch. If left empty, Traefik watches all namespaces.

    namespaces: []

    # -- A label selector can be defined to filter on specific GatewayClass objects only.

    labelselector: ""



  file:

    # -- Create a file provider

    enabled: false

    # -- Allows Traefik to automatically watch for file changes

    watch: true

    # -- File content (YAML format, go template supported) (see https://doc.traefik.io/traefik/providers/file/)

    content: ""



# -- Add volumes to the traefik pod. The volume name will be passed to tpl.

# This can be used to mount a cert pair or a configmap that holds a config.toml file.

# After the volume has been mounted, add the configs into traefik by using the `additionalArguments` list below, eg:

# `additionalArguments:

# - "--providers.file.filename=/config/dynamic.toml"

# - "--ping"

# - "--ping.entrypoint=web"`

volumes: []

# - name: public-cert

#   mountPath: "/certs"

#   type: secret

# - name: '{{ printf "%s-configs" .Release.Name }}'

#   mountPath: "/config"

#   type: configMap



# -- Additional volumeMounts to add to the Traefik container

additionalVolumeMounts: []

# -- For instance when using a logshipper for access logs

# - name: traefik-logs

#   mountPath: /var/log/traefik



logs:

  general:

    # -- Set [logs format](https://doc.traefik.io/traefik/observability/logs/#format)

    format:  # @schema enum:["common", "json", null]; type:[string, null]; default: "common"

    # By default, the level is set to INFO.

    # -- Alternative logging levels are DEBUG, PANIC, FATAL, ERROR, WARN, and INFO.

    level: "INFO"  # @schema enum:[INFO,WARN,ERROR,FATAL,PANIC,DEBUG]; default: "INFO"

    # -- To write the logs into a log file, use the filePath option.

    filePath: ""

    # -- When set to true and format is common, it disables the colorized output.

    noColor: false

  access:

    # -- To enable access logs

    enabled: false

    # -- Set [access log format](https://doc.traefik.io/traefik/observability/access-logs/#format)

    format:  # @schema enum:["CLF", "json", null]; type:[string, null]; default: "CLF"

    # filePath: "/var/log/traefik/access.log

    # -- Set [bufferingSize](https://doc.traefik.io/traefik/observability/access-logs/#bufferingsize)

    bufferingSize:  # @schema type:[integer, null]

    # -- Set [filtering](https://docs.traefik.io/observability/access-logs/#filtering)

    filters: {}

    statuscodes: ""

    retryattempts: false

    minduration: ""

    # -- Enables accessLogs for internal resources. Default: false.

    addInternals: false

    fields:

      general:

        # -- Set default mode for fields.names

        defaultmode: keep  # @schema enum:[keep, drop, redact]; default: keep

        # -- Names of the fields to limit.

        names: {}

      # -- [Limit logged fields or headers](https://doc.traefik.io/traefik/observability/access-logs/#limiting-the-fieldsincluding-headers)

      headers:

        # -- Set default mode for fields.headers

        defaultmode: drop  # @schema enum:[keep, drop, redact]; default: drop

        names: {}



metrics:

  ## -- Enable metrics for internal resources. Default: false

  addInternals: false



  ## -- Prometheus is enabled by default.

  ## -- It can be disabled by setting "prometheus: null"

  prometheus:

    # -- Entry point used to expose metrics.

    entryPoint: metrics

    ## Enable metrics on entry points. Default: true

    addEntryPointsLabels:  # @schema type:[boolean, null]

    ## Enable metrics on routers. Default: false

    addRoutersLabels:  # @schema type:[boolean, null]

    ## Enable metrics on services. Default: true

    addServicesLabels:  # @schema type:[boolean, null]

    ## Buckets for latency metrics. Default="0.1,0.3,1.2,5.0"

    buckets: ""

    ## When manualRouting is true, it disables the default internal router in

    ## order to allow creating a custom router for prometheus@internal service.

    manualRouting: false

    service:

      # -- Create a dedicated metrics service to use with ServiceMonitor

      enabled: false

      labels: {}

      annotations: {}

    # -- When set to true, it won't check if Prometheus Operator CRDs are deployed

    disableAPICheck:  # @schema type:[boolean, null]

    serviceMonitor:

      # -- Enable optional CR for Prometheus Operator. See EXAMPLES.md for more details.

      enabled: false

      metricRelabelings: []

      relabelings: []

      jobLabel: ""

      interval: ""

      honorLabels: false

      scrapeTimeout: ""

      honorTimestamps: false

      enableHttp2: false

      followRedirects: false

      additionalLabels: {}

      namespace: ""

      namespaceSelector: {}

    prometheusRule:

      # -- Enable optional CR for Prometheus Operator. See EXAMPLES.md for more details.

      enabled: false

      additionalLabels: {}

      namespace: ""



  #  datadog:

  #    ## Address instructs exporter to send metrics to datadog-agent at this address.

  #    address: "127.0.0.1:8125"

  #    ## The interval used by the exporter to push metrics to datadog-agent. Default=10s

  #    # pushInterval: 30s

  #    ## The prefix to use for metrics collection. Default="traefik"

  #    # prefix: traefik

  #    ## Enable metrics on entry points. Default=true

  #    # addEntryPointsLabels: false

  #    ## Enable metrics on routers. Default=false

  #    # addRoutersLabels: true

  #    ## Enable metrics on services. Default=true

  #    # addServicesLabels: false

  #  influxdb2:

  #    ## Address instructs exporter to send metrics to influxdb v2 at this address.

  #    address: localhost:8086

  #    ## Token with which to connect to InfluxDB v2.

  #    token: xxx

  #    ## Organisation where metrics will be stored.

  #    org: ""

  #    ## Bucket where metrics will be stored.

  #    bucket: ""

  #    ## The interval used by the exporter to push metrics to influxdb. Default=10s

  #    # pushInterval: 30s

  #    ## Additional labels (influxdb tags) on all metrics.

  #    # additionalLabels:

  #    #   env: production

  #    #   foo: bar

  #    ## Enable metrics on entry points. Default=true

  #    # addEntryPointsLabels: false

  #    ## Enable metrics on routers. Default=false

  #    # addRoutersLabels: true

  #    ## Enable metrics on services. Default=true

  #    # addServicesLabels: false

  #  statsd:

  #    ## Address instructs exporter to send metrics to statsd at this address.

  #    address: localhost:8125

  #    ## The interval used by the exporter to push metrics to influxdb. Default=10s

  #    # pushInterval: 30s

  #    ## The prefix to use for metrics collection. Default="traefik"

  #    # prefix: traefik

  #    ## Enable metrics on entry points. Default=true

  #    # addEntryPointsLabels: false

  #    ## Enable metrics on routers. Default=false

  #    # addRoutersLabels: true

  #    ## Enable metrics on services. Default=true

  #    # addServicesLabels: false

  otlp:

    # -- Set to true in order to enable the OpenTelemetry metrics

    enabled: false

    # -- Enable metrics on entry points. Default: true

    addEntryPointsLabels:  # @schema type:[boolean, null]

    # -- Enable metrics on routers. Default: false

    addRoutersLabels:  # @schema type:[boolean, null]

    # -- Enable metrics on services. Default: true

    addServicesLabels:  # @schema type:[boolean, null]

    # -- Explicit boundaries for Histogram data points. Default: [.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10]

    explicitBoundaries: []

    # -- Interval at which metrics are sent to the OpenTelemetry Collector. Default: 10s

    pushInterval: ""

    http:

      # -- Set to true in order to send metrics to the OpenTelemetry Collector using HTTP.

      enabled: false

      # -- Format: <scheme>://<host>:<port><path>. Default: http://localhost:4318/v1/metrics

      endpoint: ""

      # -- Additional headers sent with metrics by the reporter to the OpenTelemetry Collector.

      headers: {}

      ## Defines the TLS configuration used by the reporter to send metrics to the OpenTelemetry Collector.

      tls:

        # -- The path to the certificate authority, it defaults to the system bundle.

        ca: ""

        # -- The path to the public certificate. When using this option, setting the key option is required.

        cert: ""

        # -- The path to the private key. When using this option, setting the cert option is required.

        key: ""

        # -- When set to true, the TLS connection accepts any certificate presented by the server regardless of the hostnames it covers.

        insecureSkipVerify:  # @schema type:[boolean, null]

    grpc:

      # -- Set to true in order to send metrics to the OpenTelemetry Collector using gRPC

      enabled: false

      # -- Format: <scheme>://<host>:<port><path>. Default: http://localhost:4318/v1/metrics

      endpoint: ""

      # -- Allows reporter to send metrics to the OpenTelemetry Collector without using a secured protocol.

      insecure: false

      ## Defines the TLS configuration used by the reporter to send metrics to the OpenTelemetry Collector.

      tls:

        # -- The path to the certificate authority, it defaults to the system bundle.

        ca: ""

        # -- The path to the public certificate. When using this option, setting the key option is required.

        cert: ""

        # -- The path to the private key. When using this option, setting the cert option is required.

        key: ""

        # -- When set to true, the TLS connection accepts any certificate presented by the server regardless of the hostnames it covers.

        insecureSkipVerify: false



## Tracing

# -- https://doc.traefik.io/traefik/observability/tracing/overview/

tracing:  # @schema additionalProperties: false

  # -- Enables tracing for internal resources. Default: false.

  addInternals: false

  otlp:

    # -- See https://doc.traefik.io/traefik/v3.0/observability/tracing/opentelemetry/

    enabled: false

    http:

      # -- Set to true in order to send metrics to the OpenTelemetry Collector using HTTP.

      enabled: false

      # -- Format: <scheme>://<host>:<port><path>. Default: http://localhost:4318/v1/metrics

      endpoint: ""

      # -- Additional headers sent with metrics by the reporter to the OpenTelemetry Collector.

      headers: {}

      ## Defines the TLS configuration used by the reporter to send metrics to the OpenTelemetry Collector.

      tls:

        # -- The path to the certificate authority, it defaults to the system bundle.

        ca: ""

        # -- The path to the public certificate. When using this option, setting the key option is required.

        cert: ""

        # -- The path to the private key. When using this option, setting the cert option is required.

        key: ""

        # -- When set to true, the TLS connection accepts any certificate presented by the server regardless of the hostnames it covers.

        insecureSkipVerify: false

    grpc:

      # -- Set to true in order to send metrics to the OpenTelemetry Collector using gRPC

      enabled: false

      # -- Format: <scheme>://<host>:<port><path>. Default: http://localhost:4318/v1/metrics

      endpoint: ""

      # -- Allows reporter to send metrics to the OpenTelemetry Collector without using a secured protocol.

      insecure: false

      ## Defines the TLS configuration used by the reporter to send metrics to the OpenTelemetry Collector.

      tls:

        # -- The path to the certificate authority, it defaults to the system bundle.

        ca: ""

        # -- The path to the public certificate. When using this option, setting the key option is required.

        cert: ""

        # -- The path to the private key. When using this option, setting the cert option is required.

        key: ""

        # -- When set to true, the TLS connection accepts any certificate presented by the server regardless of the hostnames it covers.

        insecureSkipVerify: false



# -- Global command arguments to be passed to all traefik's pods

globalArguments:

- "--global.checknewversion"

- "--global.sendanonymoususage"



# -- Additional arguments to be passed at Traefik's binary

# See [CLI Reference](https://docs.traefik.io/reference/static-configuration/cli/)

# Use curly braces to pass values: `helm install --set="additionalArguments={--providers.kubernetesingress.ingressclass=traefik-internal,--log.level=DEBUG}"`

additionalArguments: []

#  - "--providers.kubernetesingress.ingressclass=traefik-internal"

#  - "--log.level=DEBUG"



# -- Environment variables to be passed to Traefik's binary

# @default -- See _values.yaml_

env:

- name: POD_NAME

  valueFrom:

    fieldRef:

      fieldPath: metadata.name

- name: POD_NAMESPACE

  valueFrom:

    fieldRef:

      fieldPath: metadata.namespace



# -- Environment variables to be passed to Traefik's binary from configMaps or secrets

envFrom: []



ports:

redis: # 添加此部分,用于暴露Redis对外访问
port: 6379
expose: true
exposedPort: 6379 # 对外暴露端口
protocol: TCP
mysql: #添加此部分,用于暴露MySQL对外访问
port: 3306
expose: true
exposedPort: 3306 # 对外暴露端口
protocol: TCP

  traefik:

    port: 9000

    # -- Use hostPort if set.

    hostPort:  # @schema type:[integer, null]; minimum:0

    # -- Use hostIP if set. If not set, Kubernetes will default to 0.0.0.0, which

    # means it's listening on all your interfaces and all your IPs. You may want

    # to set this value if you need traefik to listen on specific interface

    # only.

    hostIP:  # @schema type:[string, null]



    # Defines whether the port is exposed if service.type is LoadBalancer or

    # NodePort.

    #

    # -- You SHOULD NOT expose the traefik port on production deployments.

    # If you want to access it from outside your cluster,

    # use `kubectl port-forward` or create a secure ingress

    expose:

      default: false

    # -- The exposed port for this service

    exposedPort: 9000

    # -- The port protocol (TCP/UDP)

    protocol: TCP

  web:

    ## -- Enable this entrypoint as a default entrypoint. When a service doesn't explicitly set an entrypoint it will only use this entrypoint.

    # asDefault: true

    port: 8000

    # hostPort: 8000

    # containerPort: 8000

    expose:

      default: true

    exposedPort: 80

    ## -- Different target traefik port on the cluster, useful for IP type LB

    targetPort:  # @schema type:[integer, null]; minimum:0

    # The port protocol (TCP/UDP)

    protocol: TCP

    # -- See [upstream documentation](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport)

    nodePort:  # @schema type:[integer, null]; minimum:0

    # Port Redirections

    # Added in 2.2, you can make permanent redirects via entrypoints.

    # https://docs.traefik.io/routing/entrypoints/#redirection

    redirectTo: {}

    forwardedHeaders:

      # -- Trust forwarded headers information (X-Forwarded-*).

      trustedIPs: []

      insecure: false

    proxyProtocol:

      # -- Enable the Proxy Protocol header parsing for the entry point

      trustedIPs: []

      insecure: false

    # -- Set transport settings for the entrypoint; see also

    # https://doc.traefik.io/traefik/routing/entrypoints/#transport

    transport:

      respondingTimeouts:

        readTimeout:   # @schema type:[string, integer, null]

        writeTimeout:  # @schema type:[string, integer, null]

        idleTimeout:   # @schema type:[string, integer, null]

      lifeCycle:

        requestAcceptGraceTimeout:  # @schema type:[string, integer, null]

        graceTimeOut:               # @schema type:[string, integer, null]

      keepAliveMaxRequests:         # @schema type:[integer, null]; minimum:0

      keepAliveMaxTime:             # @schema type:[string, integer, null]

  websecure:

    ## -- Enable this entrypoint as a default entrypoint. When a service doesn't explicitly set an entrypoint it will only use this entrypoint.

    # asDefault: true

    port: 8443

    hostPort:  # @schema type:[integer, null]; minimum:0

    containerPort:  # @schema type:[integer, null]; minimum:0

    expose:

      default: true

    exposedPort: 443

    ## -- Different target traefik port on the cluster, useful for IP type LB

    targetPort:  # @schema type:[integer, null]; minimum:0

    ## -- The port protocol (TCP/UDP)

    protocol: TCP

    # -- See [upstream documentation](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport)

    nodePort:  # @schema type:[integer, null]; minimum:0

    # -- See [upstream documentation](https://kubernetes.io/docs/concepts/services-networking/service/#application-protocol)

    appProtocol:  # @schema type:[string, null]

    # -- See [upstream documentation](https://doc.traefik.io/traefik/routing/entrypoints/#allowacmebypass)

    allowACMEByPass: false

    http3:

      ## -- Enable HTTP/3 on the entrypoint

      ## Enabling it will also enable http3 experimental feature

      ## https://doc.traefik.io/traefik/routing/entrypoints/#http3

      ## There are known limitations when trying to listen on same ports for

      ## TCP & UDP (Http3). There is a workaround in this chart using dual Service.

      ## https://github.com/kubernetes/kubernetes/issues/47249#issuecomment-587960741

      enabled: false

      advertisedPort:  # @schema type:[integer, null]; minimum:0

    forwardedHeaders:

        # -- Trust forwarded headers information (X-Forwarded-*).

      trustedIPs: []

      insecure: false

    proxyProtocol:

      # -- Enable the Proxy Protocol header parsing for the entry point

      trustedIPs: []

      insecure: false

    # -- See [upstream documentation](https://doc.traefik.io/traefik/routing/entrypoints/#transport)

    transport:

      respondingTimeouts:

        readTimeout:   # @schema type:[string, integer, null]

        writeTimeout:  # @schema type:[string, integer, null]

        idleTimeout:   # @schema type:[string, integer, null]

      lifeCycle:

        requestAcceptGraceTimeout:  # @schema type:[string, integer, null]

        graceTimeOut:               # @schema type:[string, integer, null]

      keepAliveMaxRequests:         # @schema type:[integer, null]; minimum:0

      keepAliveMaxTime:             # @schema type:[string, integer, null]

    # --  See [upstream documentation](https://doc.traefik.io/traefik/routing/entrypoints/#tls)

    tls:

      enabled: true

      options: ""

      certResolver: ""

      domains: []

    # -- One can apply Middlewares on an entrypoint

    # https://doc.traefik.io/traefik/middlewares/overview/

    # https://doc.traefik.io/traefik/routing/entrypoints/#middlewares

    # -- /!\ It introduces here a link between your static configuration and your dynamic configuration /!\

    # It follows the provider naming convention: https://doc.traefik.io/traefik/providers/overview/#provider-namespace

    #   - namespace-name1@kubernetescrd

    #   - namespace-name2@kubernetescrd

    middlewares: []

  metrics:

    # -- When using hostNetwork, use another port to avoid conflict with node exporter:

    # https://github.com/prometheus/prometheus/wiki/Default-port-allocations

    port: 9100

    # -- You may not want to expose the metrics port on production deployments.

    # If you want to access it from outside your cluster,

    # use `kubectl port-forward` or create a secure ingress

    expose:

      default: false

    # -- The exposed port for this service

    exposedPort: 9100

    # -- The port protocol (TCP/UDP)

    protocol: TCP



# -- TLS Options are created as [TLSOption CRDs](https://doc.traefik.io/traefik/https/tls/#tls-options)

# When using `labelSelector`, you'll need to set labels on tlsOption accordingly.

# See EXAMPLE.md for details.

tlsOptions: {}



# -- TLS Store are created as [TLSStore CRDs](https://doc.traefik.io/traefik/https/tls/#default-certificate). This is useful if you want to set a default certificate. See EXAMPLE.md for details.

tlsStore: {}



service:

  enabled: true

  ## -- Single service is using `MixedProtocolLBService` feature gate.

  ## -- When set to false, it will create two Service, one for TCP and one for UDP.

  single: true

  type: LoadBalancer

  # -- Additional annotations applied to both TCP and UDP services (e.g. for cloud provider specific config)

  annotations: {}

  # -- Additional annotations for TCP service only

  annotationsTCP: {}

  # -- Additional annotations for UDP service only

  annotationsUDP: {}

  # -- Additional service labels (e.g. for filtering Service by custom labels)

  labels: {}

  # -- Additional entries here will be added to the service spec.

  # -- Cannot contain type, selector or ports entries.

  spec: {}

  # externalTrafficPolicy: Cluster

  # loadBalancerIP: "1.2.3.4"

  # clusterIP: "2.3.4.5"

  loadBalancerSourceRanges: []

  # - 192.168.0.1/32

  # - 172.16.0.0/16

  ## -- Class of the load balancer implementation

  # loadBalancerClass: service.k8s.aws/nlb

  externalIPs: []

  # - 1.2.3.4

  ## One of SingleStack, PreferDualStack, or RequireDualStack.

  # ipFamilyPolicy: SingleStack

  ## List of IP families (e.g. IPv4 and/or IPv6).

  ## ref: https://kubernetes.io/docs/concepts/services-networking/dual-stack/#services

  # ipFamilies:

  #   - IPv4

  #   - IPv6

  ##

  additionalServices: {}

  ## -- An additional and optional internal Service.

  ## Same parameters as external Service

  # internal:

  #   type: ClusterIP

  #   # labels: {}

  #   # annotations: {}

  #   # spec: {}

  #   # loadBalancerSourceRanges: []

  #   # externalIPs: []

  #   # ipFamilies: [ "IPv4","IPv6" ]



autoscaling:

  # -- Create HorizontalPodAutoscaler object.

  # See EXAMPLES.md for more details.

  enabled: false



persistence:

  # -- Enable persistence using Persistent Volume Claims

  # ref: http://kubernetes.io/docs/user-guide/persistent-volumes/

  # It can be used to store TLS certificates, see `storage` in certResolvers

  enabled: false

  name: data

  existingClaim: ""

  accessMode: ReadWriteOnce

  size: 128Mi

  storageClass: ""

  volumeName: ""

  path: /data

  annotations: {}

  # -- Only mount a subpath of the Volume into the pod

  subPath: ""



# -- Certificates resolvers configuration.

# Ref: https://doc.traefik.io/traefik/https/acme/#certificate-resolvers

# See EXAMPLES.md for more details.

certResolvers: {}



# -- If hostNetwork is true, runs traefik in the host network namespace

# To prevent unschedulabel pods due to port collisions, if hostNetwork=true

# and replicas>1, a pod anti-affinity is recommended and will be set if the

# affinity is left as default.

hostNetwork: false



# -- Whether Role Based Access Control objects like roles and rolebindings should be created

rbac:  # @schema additionalProperties: false

  enabled: true

  # When set to true:

  # 1. Use `Role` and `RoleBinding` instead of `ClusterRole` and `ClusterRoleBinding`.

  # 2. Set `disableIngressClassLookup` on Kubernetes Ingress providers with Traefik Proxy v3 until v3.1.1

  # 3. Set `disableClusterScopeResources` on Kubernetes Ingress and CRD providers with Traefik Proxy v3.1.2+

  # **NOTE**: `IngressClass`, `NodePortLB` and **Gateway** provider cannot be used with namespaced RBAC.

  # See [upstream documentation](https://doc.traefik.io/traefik/providers/kubernetes-ingress/#disableclusterscoperesources) for more details.

  namespaced: false

  # Enable user-facing roles

  # https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles

  aggregateTo: []

  # List of Kubernetes secrets that are accessible for Traefik. If empty, then access is granted to every secret.

  secretResourceNames: []



# -- Enable to create a PodSecurityPolicy and assign it to the Service Account via RoleBinding or ClusterRoleBinding

podSecurityPolicy:

  enabled: false



# -- The service account the pods will use to interact with the Kubernetes API

serviceAccount:  # @schema additionalProperties: false

  # If set, an existing service account is used

  # If not set, a service account is created automatically using the fullname template

  name: ""



# -- Additional serviceAccount annotations (e.g. for oidc authentication)

serviceAccountAnnotations: {}



# -- [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) for `traefik` container.

resources: {}



# -- This example pod anti-affinity forces the scheduler to put traefik pods

# -- on nodes where no other traefik pods are scheduled.

# It should be used when hostNetwork: true to prevent port conflicts

affinity: {}

#  podAntiAffinity:

#    requiredDuringSchedulingIgnoredDuringExecution:

#      - labelSelector:

#          matchLabels:

#            app.kubernetes.io/name: '{{ template "traefik.name" . }}'

#            app.kubernetes.io/instance: '{{ .Release.Name }}-{{ .Release.Namespace }}'

#        topologyKey: kubernetes.io/hostname



# -- nodeSelector is the simplest recommended form of node selection constraint.

nodeSelector: {}

# -- Tolerations allow the scheduler to schedule pods with matching taints.

tolerations: []

# -- You can use topology spread constraints to control

# how Pods are spread across your cluster among failure-domains.

topologySpreadConstraints: []

# This example topologySpreadConstraints forces the scheduler to put traefik pods

# on nodes where no other traefik pods are scheduled.

#  - labelSelector:

#      matchLabels:

#        app: '{{ template "traefik.name" . }}'

#    maxSkew: 1

#    topologyKey: kubernetes.io/hostname

#    whenUnsatisfiable: DoNotSchedule



# -- [Pod Priority and Preemption](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)

priorityClassName: ""



# -- [SecurityContext](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context-1)

# @default -- See _values.yaml_

securityContext:

  allowPrivilegeEscalation: false

  capabilities:

    drop: [ALL]

  readOnlyRootFilesystem: true



# -- [Pod Security Context](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context)

# @default -- See _values.yaml_

podSecurityContext:

  runAsGroup: 65532

  runAsNonRoot: true

  runAsUser: 65532



#

# -- Extra objects to deploy (value evaluated as a template)

#

# In some cases, it can avoid the need for additional, extended or adhoc deployments.

# See #595 for more details and traefik/tests/values/extra.yaml for example.

extraObjects: []



# -- This field override the default Release Namespace for Helm.

# It will not affect optional CRDs such as `ServiceMonitor` and `PrometheusRules`

namespaceOverride: ""



## -- This field override the default app.kubernetes.io/instance label for all Objects.

instanceLabelOverride: ""



# Traefik Hub configuration. See https://doc.traefik.io/traefik-hub/

hub:

  # -- Name of `Secret` with key 'token' set to a valid license token.

  # It enables API Gateway.

  token: ""

  apimanagement:

    # -- Set to true in order to enable API Management. Requires a valid license token.

    enabled: false

    admission:

      # -- WebHook admission server listen address. Default: "0.0.0.0:9943".

      listenAddr: ""

      # -- Certificate of the WebHook admission server. Default: "hub-agent-cert".

      secretName: ""



  ratelimit:

    redis:

      # -- Enable Redis Cluster. Default: true.

      cluster:    # @schema type:[boolean, null]

      # -- Database used to store information. Default: "0".

      database:   # @schema type:[string, null]

      # -- Endpoints of the Redis instances to connect to. Default: "".

      endpoints: ""

      # -- The username to use when connecting to Redis endpoints. Default: "".

      username: ""

      # -- The password to use when connecting to Redis endpoints. Default: "".

      password: ""

      sentinel:

        # -- Name of the set of main nodes to use for main selection. Required when using Sentinel. Default: "".

        masterset: ""

        # -- Username to use for sentinel authentication (can be different from endpoint username). Default: "".

        username: ""

        # -- Password to use for sentinel authentication (can be different from endpoint password). Default: "".

        password: ""

      # -- Timeout applied on connection with redis. Default: "0s".

      timeout: ""

      tls:

        # -- Path to the certificate authority used for the secured connection.

        ca: ""

        # -- Path to the public certificate used for the secure connection.

        cert: ""

        # -- Path to the private key used for the secure connection.

        key: ""

        # -- When insecureSkipVerify is set to true, the TLS connection accepts any certificate presented by the server. Default: false.

        insecureSkipVerify: false

  # Enable export of errors logs to the platform. Default: true.

  sendlogs:  # @schema type:[boolean, null]

应用配置

1
2
3
helm upgrade traefik traefik/traefik \
--namespace traefik -f traefik-values.yaml

IngressRouteTCP示例

mysql-traefik-ingress.yaml

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
32
33
34
35
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql
namespace: default
spec:
...
---
apiVersion: v1
kind: Service
metadata:
name: mysql-svc
namespace: default
spec:
selector:
app: mysql
ports:
- port: 3306
name: mysql-tcp
protocol: TCP
clusterIP: None # 定义Headless Service
---
apiVersion: traefik.io/v1alpha1
kind: IngressRouteTCP
metadata:
name: mysql-ingress
namespace: default #根据实际情况修改,或应用文件时指定
spec:
entryPoints:
- mysql
routes:
- match: HostSNI(`*`)
services:
- name: mysql-svc
namespace: default

一、问题背景与准备工作

当您忘记 MySQL 的 root 密码,或者怀疑密码被篡改(例如服务器遭受攻击)时,可以通过进入 MySQL 的“安全模式”来重置密码。此方法适用于 MySQL 5.7 及更高版本。

重要前提:您需要拥有操作系统的管理员权限,并能访问 MySQL 的安装目录。


二、核心步骤:进入安全模式并重置密码

2.1 第一步:停止 MySQL 服务

首先,必须停止正在运行的 MySQL 服务。

方法 A:使用命令提示符(推荐)

1
net stop mysql

注意:服务名可能因安装版本而异(如 mysql57mysql80)。如果上述命令失败,请打开“服务”管理面板(services.msc)查找准确的 MySQL 服务名称。

方法 B:通过服务管理面板

  1. Win + R,输入 services.msc 并回车。
  2. 在服务列表中找到 MySQL 服务(如 “MySQL57”)。
  3. 右键点击,选择“停止”。

2.2 第二步:以无授权表模式启动 MySQL

此模式允许您无需密码即可连接数据库。

  1. 打开新的命令提示符窗口(管理员身份)

  2. 切换到 MySQL 的 bin 目录

    1
    cd “C:\Program Files\MySQL\MySQL Server 5.7\bin”

    请根据您的实际安装路径调整。

  3. 启动 MySQL 并跳过权限验证

    • 标准命令
      1
      mysqld --skip-grant-tables
    • 如果配置了 my.ini 文件(通常指定了数据目录),必须引入配置文件:
      1
      mysqld --defaults-file=”../my.ini” --skip-grant-tables
      配置文件 my.ini 通常位于 C:\ProgramData\MySQL\MySQL Server X.X\ 目录下。
  4. 此时,当前窗口会挂起,显示 MySQL 已启动。请勿关闭此窗口

2.3 第三步:连接数据库并清空 root 密码

  1. 打开另一个新的命令提示符窗口(管理员身份)

  2. 同样切换到 MySQL 的 bin 目录

  3. 无密码连接 MySQL

    1
    mysql -u root

    成功连接后,会看到 mysql> 提示符。

  4. 切换到 mysql 系统数据库并清空 root 密码

    1
    2
    3
    4
    5
    USE mysql;
    -- 对于 MySQL 5.7+,密码存储在 `authentication_string` 字段
    UPDATE user SET authentication_string=’’ WHERE user=’root’;
    -- 对于 MySQL 5.6 及更早版本,使用 `password` 字段
    -- UPDATE user SET password=’’ WHERE user=’root’;

    执行成功后,会提示 Query OK, 1 row affected

  5. 刷新权限并退出

    1
    2
    FLUSH PRIVILEGES;
    QUIT;

2.4 第四步:重启 MySQL 服务

  1. 返回到运行 mysqld --skip-grant-tables 的命令窗口,按 Ctrl + C 终止进程。
  2. 或者,打开任务管理器,结束 mysqld.exe 进程。
  3. 重新启动 MySQL 服务:
    1
    net start mysql
    (同样,请使用您的实际服务名)

至此,root 密码已被清空。您可以使用 mysql -u root 直接登录,无需密码。


三、为 root 账户设置新密码(安全加固)

出于安全考虑,必须为 root 账户设置一个强密码。登录后,可选择以下任一方法。

3.1 方法一:使用 SET PASSWORD 命令(推荐)

1
2
3
4
5
6
7
8
-- 登录 MySQL
mysql -u root

-- 修改密码(MySQL 5.7+ 语法)
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘您的新密码’;

-- 或使用传统语法(某些版本支持)
SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘您的新密码’);

3.2 方法二:使用 mysqladmin 命令行工具

在命令提示符(非 MySQL 客户端)中操作:

1
mysqladmin -u root password “您的新密码”

注意:如果 root 已有密码,需要使用 -p 参数输入旧密码。此方法会因在命令行中暴露密码而收到安全警告。

3.3 方法三:直接更新 user

在 MySQL 客户端内执行:

1
2
3
4
5
6
7
USE mysql;
-- 对于 MySQL 5.7+
UPDATE user SET authentication_string = PASSWORD(‘您的新密码’) WHERE user = ‘root’;
-- 对于旧版本
-- UPDATE user SET password = PASSWORD(‘您的新密码’) WHERE user = ‘root’;

FLUSH PRIVILEGES;

无论使用哪种方法,修改密码后都必须执行 FLUSH PRIVILEGES; 使更改立即生效。


四、故障排除与注意事项

4.1 常见错误与解决

  • 错误:mysqld: [ERROR] Found option without preceding group in config file
    原因my.ini 配置文件编码或格式错误(例如保存为 UTF-8 with BOM)。
    解决:使用记事本打开 my.ini,另存为 ANSI 编码。

  • 错误:No such file or directory
    原因:未指定正确的 my.ini 路径,或数据目录不存在。
    解决:使用 --defaults-file 参数明确指定配置文件完整路径。

  • 服务无法启动
    解决:检查事件查看器(eventvwr.msc)中 “应用程序” 日志的 MySQL 错误信息。

4.2 安全建议

  1. 立即修改密码:重置后,务必立即设置一个强密码。
  2. 检查用户:登录后,执行 SELECT user, host FROM mysql.user;,检查是否有未知或可疑账户。
  3. 考虑重装:如果服务器确认被入侵,重置密码仅是第一步,建议全面安全检查,甚至考虑备份数据后重装 MySQL。
  4. 使用强密码:密码应包含大小写字母、数字和特殊字符,长度至少12位。

4.3 不同 MySQL 版本的差异

版本 密码字段 修改密码推荐命令
MySQL 5.7+ authentication_string ALTER USER … IDENTIFIED BY ‘密码’;
MySQL 5.6 及更早 password SET PASSWORD = PASSWORD(‘密码’);

五、总结操作流程

  1. 停止服务net stop mysql
  2. 无授权启动:在 bin 目录运行 mysqld --skip-grant-tables(必要时加 --defaults-file)。
  3. 无密码连接:新窗口运行 mysql -u root
  4. 清空密码:执行 UPDATE mysql.user SET authentication_string=’’ WHERE user=’root’;FLUSH PRIVILEGES;
  5. 重启服务:结束 mysqld 进程,运行 net start mysql
  6. 设置新密码:登录后使用 ALTER USER 命令设置强密码。
  7. 安全检查:审查用户列表,确保无其他安全隐患。

一、概述与准备工作

1.1 GPU 加速的优势与局限

优势

  • 速度极快:GPU 拥有强大的并行计算能力,视频编解码速度远超 CPU。
  • 释放 CPU:将繁重的视频处理任务卸载到 GPU,让 CPU 专注于其他应用。

局限

  • 质量与体积:GPU 编码器(硬件编码)的压缩效率通常低于 CPU 编码器(软件编码,如 libx264)。在相同码率下,GPU 编码的视频质量可能稍差,或为达到相同质量需要更大的文件体积。
  • 功能限制:GPU 编码器支持的编码参数(如 crfpreset)通常比软件编码器少。

适用场景:适用于对处理速度要求极高,且对最终文件体积或极致画质要求不苛刻的场景,如实时流媒体、大规模视频转码批处理。

1.2 下载 FFmpeg

  1. 访问 FFmpeg 官网下载页:https://ffmpeg.org/download.html
  2. 对于 Windows 用户,建议直接下载编译好的版本,例如来自 gyan.devBtbN 的构建包。
  3. 下载后解压,将 bin 目录路径(如 C:\ffmpeg\bin)添加到系统的 PATH 环境变量中,以便在命令行中直接使用 ffmpeg 命令。

二、NVIDIA GPU 加速配置与使用

2.1 安装 CUDA 驱动(必需)

FFmpeg 的 NVIDIA GPU 加速依赖于 NVIDIA 的 CUDANVENC/NVDEC 驱动。

  1. 访问 NVIDIA 开发者网站:https://developer.nvidia.com/cuda-downloads
  2. 选择适合你系统的版本(操作系统、架构、版本、安装类型)。对于大多数用户,选择 Windows -> x86_64 -> 10 -> exe(local) 即可。
  3. 下载并运行安装程序,按提示完成安装。

2.2 检查 FFmpeg 是否支持 CUDA/NVENC

在命令提示符中运行以下命令,查看支持的硬件加速方法:

1
ffmpeg -hwaccels

如果输出中包含 cudacuvidnvdec,则说明当前 FFmpeg 版本支持 NVIDIA 硬件加速。

2.3 核心命令与参数详解

一个完整的 NVIDIA GPU 加速转码命令包含硬件解码处理硬件编码三个部分。

基础命令结构

1
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i input.mp4 -c:v h264_nvenc -y output.mp4

参数分解

参数 作用 说明
-hwaccel cuvid 指定使用 CUDA 视频加速 API 进行解码。 也可用 nvdec(更新)。
-c:v h264_cuvid 硬件解码器。指定使用 NVIDIA 的 H.264 解码器。 根据输入视频编码格式选择:hevc_cuvid (H.265), mpeg2_cuvid, vp9_cuvid 等。
-i input.mp4 输入文件。
-c:v h264_nvenc 硬件编码器。指定使用 NVIDIA 的 H.264 编码器。 可选:hevc_nvenc (H.265), av1_nvenc
-y 覆盖输出文件。
output.mp4 输出文件。

2.4 常用转码示例

1. 改变码率(控制体积)

1
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i input.mp4 -c:v h264_nvenc -b:v 2000k -y output.mp4

-b:v 2000k:将视频码率设置为 2000 Kbps。

2. 改变帧率

1
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i input.mp4 -c:v h264_nvenc -r 30 -y output.mp4

-r 30:将输出视频帧率设置为 30 fps。

3. 缩放分辨率(使用 GPU 滤镜)

1
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i input.mp4 -c:v h264_nvenc -vf "scale_npp=1280:-2" -y output.mp4

-vf "scale_npp=1280:-2":使用 NVIDIA 的 scale_npp 滤镜将宽度缩放到 1280 像素,高度按比例自动计算(-2 保证为偶数)。注意:GPU 滤镜与 CPU 滤镜(scale)不同。

4. 综合示例(转码、缩放、修改码率)

1
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i input.mp4 -c:v h264_nvenc -b:v 1500k -vf "scale_npp=1920:1080" -r 25 -y output.mp4

2.5 多 GPU 系统指定设备

如果系统装有多个 NVIDIA GPU,可以使用 -hwaccel_device 参数指定使用哪一块 GPU。

1
2
3
4
5
# 使用第一块 GPU (索引 0)
ffmpeg -hwaccel cuvid -hwaccel_device 0 -c:v h264_cuvid -i input.mp4 -c:v h264_nvenc -y output_gpu0.mp4

# 使用第二块 GPU (索引 1)
ffmpeg -hwaccel cuvid -hwaccel_device 1 -c:v h264_cuvid -i input.mp4 -c:v h264_nvenc -y output_gpu1.mp4

性能提示:单个 GPU 通常在同一时间只能高效处理一个编码任务。多个转码任务不会自动分配到不同 GPU,需要手动指定。


三、AMD GPU 加速配置与使用

AMD GPU 加速无需安装额外的 SDK(如 CUDA),只要 FFmpeg 编译时启用了 AMF(AMD Media Framework)支持即可。大多数预编译的 Windows 版 FFmpeg 已包含此支持。

3.1 检查 AMF 支持

运行以下命令,查看编码器列表:

1
ffmpeg -encoders | findstr amf

如果看到 h264_amfhevc_amf 等编码器,则说明支持 AMD GPU 加速。

3.2 核心命令示例

基础转码命令

1
ffmpeg -i input.mp4 -c:v h264_amf -y output.mp4

参数比 NVIDIA 方案更简洁,因为 AMD 目前主要提供硬件编码器,解码通常仍由 CPU 或通用硬件解码器完成。

调整编码参数
AMD AMF 编码器支持一些特定的参数来控制质量和速度。

1
ffmpeg -i input.mp4 -c:v h264_amf -quality quality -y output.mp4

-quality:可设置为 speed(速度优先)、balanced(平衡)或 quality(质量优先)。

更多参数示例

1
ffmpeg -i input.mp4 -c:v h264_amf -b:v 3M -usage transcoding -profile high -y output.mp4
  • -usage transcoding:指定为转码用途。
  • -profile high:指定 H.264 High Profile。

四、Intel GPU 加速(Quick Sync Video, QSV)

许多 Intel 酷睿处理器集成了核芯显卡,支持 QSV 技术,也可用于 FFmpeg 加速。

4.1 命令示例

基础命令

1
ffmpeg -hwaccel qsv -c:v h264_qsv -i input.mp4 -c:v h264_qsv -y output.mp4
  • -hwaccel qsv:启用 QSV 硬件加速。
  • -c:v h264_qsv:既作解码器也作编码器。

使用不同的编解码器

1
2
# H.265/HEVC 编解码
ffmpeg -hwaccel qsv -c:v hevc_qsv -i input.hevc -c:v hevc_qsv -y output.mp4

五、通用建议与故障排除

5.1 如何选择编解码器?

  1. 查看支持的编码器ffmpeg -encoders
  2. 查看支持的解码器ffmpeg -decoders
  3. 在输出中查找 nvencamfqsv 等关键词。

5.2 常见问题

  • 错误:Driver does not support the required nvenc API version
    原因:GPU 驱动或 FFmpeg 版本太旧。
    解决:更新 NVIDIA 显卡驱动至最新版,并使用最新的 FFmpeg 构建。

  • 错误:No NVENC capable devices found
    原因:消费级 GPU 的 NVENC 会话数有上限,或 GPU 不支持。
    解决:检查 GPU 是否支持 NVENC(GeForce 600 系列后基本都支持)。关闭其他占用 NVENC 的程序。

  • AMD/Intel 加速未生效
    解决:确保在 BIOS/UEFI 中已启用集成显卡,并且安装了最新的显卡驱动。

5.3 质量与速度的权衡

  • 追求极限压缩率/画质:使用 CPU 软件编码,如 -c:v libx264 -crf 23 -preset slow
  • 追求极限速度:使用 GPU 硬件编码,并选择 -preset fast(如 -preset p7 用于 NVENC)。
  • 平衡之选:可以考虑使用 GPU 解码 + CPU 编码(-c:v libx264),或使用 GPU 编码但设置较高的码率来弥补画质损失。

5.4 监控 GPU 使用情况

  • NVIDIA:使用 nvidia-smi 命令监控 GPU 利用率、显存占用和编码会话。
  • 任务管理器:在“性能”选项卡中查看 GPU 的“视频编码”利用率。

六、总结

平台 加速类型 关键参数 特点
NVIDIA 解码 + 编码 -hwaccel cuvid, -c:v h264_cuvid, -c:v h264_nvenc 生态完善,文档丰富,多 GPU 支持好。
AMD 主要编码 -c:v h264_amf 无需额外 SDK,配置简单。
Intel 解码 + 编码 -hwaccel qsv, -c:v h264_qsv 适合笔记本和台式机核显,功耗低。

最终建议

  1. 根据你的显卡型号选择对应的方案。
  2. 首次使用时,先用一段短视频测试命令是否可行。
  3. 对于生产环境,务必对比输出视频的质量、体积和处理速度,找到符合你需求的最佳参数组合。
0%