Configure Gitea Actions Cache Port and UFW Rules
问题背景
Gitea Actions 默认使用动态端口启动 runner cache 服务,每次重启后端口会变化,导致防火墙规则难以固定。本文介绍如何固定缓存端口并配置 UFW 规则。
固定 Cache Port
编辑 Gitea 配置文件 custom/app.ini:
[actions]
CACHE_PORT = 30001
重启 Gitea 后生效。
配置 UFW 规则
允许 Docker 网络访问缓存端口:
# 查看 Docker 默认网桥 IP
docker network inspect bridge | grep Gateway
# 通常是 172.17.0.1,添加 UFW 规则
ufw allow from 172.17.0.0/16 to any port 30001 proto tcp
验证
# 检查端口是否监听
ss -tlnp | grep 30001
# 测试连通性
curl -v http://hostip:30001
注意事项
- 确保 UFW 已启用且规则正确加载
- Docker 容器通过网桥网络访问宿主机端口
- 如使用 Docker Compose,检查网络配置是否一致