Add files via upload

This commit is contained in:
vipmc838
2025-06-04 19:36:44 +08:00
committed by GitHub
commit 3a29308c57
4 changed files with 218 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
FROM alpine:latest
WORKDIR /app
# 设置环境变量默认值(可在 docker run 时覆盖)
ENV SERVER_DOMAIN=example.clawcloudrun.com
ENV UDP_PORT=5678
ENV PASSWORD=your-uuid-password
ARG DASHBOARD_VERSION=latest
ENV DASHBOARD_VERSION=$DASHBOARD_VERSION
# 安装依赖 & 创建必要目录
RUN apk update && \
apk add --no-cache curl wget openssl bash jq unzip ca-certificates && \
mkdir -p /etc/hysteria
# 下载 hysteria2 主程序
RUN wget -q -O /usr/local/bin/hysteria https://download.hysteria.network/app/latest/hysteria-linux-amd64 && \
chmod +x /usr/local/bin/hysteria
# 自签 TLS 证书
RUN openssl req -x509 -nodes -newkey ec:<(openssl ecparam -name prime256v1) \
-keyout /etc/hysteria/server.key \
-out /etc/hysteria/server.crt \
-subj "/CN=bing.com" -days 36500
# 下载并解压 nezha-agent
RUN set -eux; \
if [ "$DASHBOARD_VERSION" = "latest" ]; then \
API_URL="https://gitee.com/api/v5/repos/naibahq/agent/releases/latest"; \
else \
API_URL="https://gitee.com/api/v5/repos/naibahq/agent/releases/tags/$DASHBOARD_VERSION"; \
fi; \
AGENT_URL=$(curl -s $API_URL | jq -r '.assets[] | select(.name | endswith("linux_amd64.zip")) | .browser_download_url'); \
if [ -z "$AGENT_URL" ] || [ "$AGENT_URL" = "null" ]; then \
echo "❌ 获取 Agent 下载地址失败,退出"; exit 1; \
fi; \
wget -O nezha-agent.zip "$AGENT_URL"; \
unzip nezha-agent.zip; \
rm nezha-agent.zip; \
chmod +x nezha-agent
# 拷贝 entrypoint 启动脚本
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# 显示 UDP 端口
EXPOSE ${UDP_PORT}/udp
# 启动脚本作为容器入口
ENTRYPOINT ["/entrypoint.sh"]
+96
View File
@@ -0,0 +1,96 @@
# Claw Cloud Hysteria2 + Nezha Agent Docker 镜像
![Docker 镜像大小](https://img.shields.io/docker/image-size/mc838/claw-hy2-agent/latest)
![Docker 拉取次数](https://img.shields.io/docker/pulls/mc838/claw-hy2-agent)
![Nezha Agent License](https://img.shields.io/github/license/nezhahq/agent)
![Hysteria License](https://img.shields.io/github/license/HyNetwork/hysteria)
这是一个用于claw.cloud部署 [Hysteria2 + Nezha Agent](https://github.com/vipmc838/claw-hy2-agent) 的轻量级 Docker 镜像。
---
## 🚀 特性
- 使用 Alpine Linux 轻量基础镜像
- 支持环境变量自定义服务端配置
- 自动生成自签 TLS 证书
- 自动从 Gitee 获取指定版本的 Nezha Agent 并启动
- 输出客户端连接字符串,方便快速配置客户端
---
## 📦 Docker 镜像
**镜像地址**[mc838/claw-hy2-agent](https://hub.docker.com/r/mc838/claw-hy2-agent)
---
## 🛠️ 环境变量说明
| 环境变量 | 说明 | 示例值 |
|---------------------|------------------------------|------------------------------------------------|
| `NZ_SERVER` | 哪吒面板地址(含端口) | `abc.com:443` |
| `NZ_UUID` | Agent 的唯一标识 UUID | `a6b091a6-679b-47d1-bc72-a4ac78ba2888` |
| `NZ_CLIENT_SECRET` | 面板端密钥,用于身份验证 | `4z0HWnSGJ8KFtKOlfJxSk8C3F8PIJ888` |
| `NZ_TLS` | 是否启用 TLStrue/false | `true` |
| `DASHBOARD_VERSION` | 指定版本(可选,默认最新) | `v1.12.2` |
| `SERVER_DOMAIN` | 爪云分配的外网域名用于客户端 | `abc.eu-central-1.clawcloudrun.com` |
| `UDP_PORT` | 内网 UDP 端口 | `20000-50000` |
| `PASSWORD` | 客户端密钥,用于身份验证) | `a6b091a6-679b-47d1-bc72-a4ac78ba2778` |
---
## 1. 通过 claw.cloud 部署
1. **Application Name(应用程序名称)**
随便填写
2. **Image(镜像地址)**
```env
mc838/claw-hy2-agent
```
3. **Usage(机器性能配置)**
- CPU = 0.1
- Memory = 64M
4. **Network(添加网络)**
- 网络端口设置:
- 开启 80 端口 选grpcs://
- 开启 20000 端口 选udp://
- 所有端口都选 Public(公网)
5. **Environment Variables(环境变量)**
```env
NZ_SERVER=abc.com:443
NZ_UUID=a6b091a6-679b-47d1-bc72-a4ac78ba2888
NZ_CLIENT_SECRET=4z0HWnSGJ8KFtKOlfJxSk8C3F8PIJ888
NZ_TLS=true
DASHBOARD_VERSION=v1.12.2
SERVER_DOMAIN=abc.eu-central-1.clawcloudrun.com
UDP_PORT=20000
PASSWORD=a6b091a6-679b-47d1-bc72-a4ac78ba2778
```
✅ 设置完成后即可点击部署。
---
6. **Pod List(客户端连接配置)**
- 在日志中查看节点信息
- 示例输出如下:
![示例输出](./ui.png)
## 鸣谢
- [Hysteria2](https://github.com/HyNetwork/hysteria)
- [哪吒监控 Agent](https://github.com/naibahq/agent)
---
## 免责声明
- 本程序仅供学习了解,非盈利目的,请于下载后 24 小时内删除,不得用作任何商业用途,文字、数据及图片均有所属版权,如转载须注明来源。
- 使用本程序必须遵守部署服务器所在地、所在国家和用户所在国家的法律法规,程序作者不对使用者任何不当行为负责。
+72
View File
@@ -0,0 +1,72 @@
#!/bin/bash
set -e
echo "✅ 正在启动 Nezha Agent,配置如下:"
echo "NZ_SERVER: ${NZ_SERVER}"
echo "NZ_UUID: ${NZ_UUID}"
echo "NZ_CLIENT_SECRET: ${NZ_CLIENT_SECRET}"
echo "NZ_TLS: ${NZ_TLS}"
echo "DASHBOARD_VERSION: ${DASHBOARD_VERSION:-latest}"
# 生成 Nezha Agent 配置
cat > /app/config.yaml <<EOF
debug: true
disable_auto_update: true
disable_command_execute: false
disable_force_update: true
disable_nat: false
disable_send_query: false
gpu: false
insecure_tls: false
ip_report_period: 1800
report_delay: 4
server: ${NZ_SERVER}
skip_connection_count: false
skip_procs_count: false
temperature: false
tls: ${NZ_TLS}
use_gitee_to_upgrade: false
use_ipv6_country_code: false
uuid: ${NZ_UUID}
client_secret: ${NZ_CLIENT_SECRET}
EOF
echo "✅ 正在启动 Hysteria2,配置如下:"
echo "SERVER_DOMAIN: ${SERVER_DOMAIN}"
echo "UDP_PORT: ${UDP_PORT}"
echo "PASSWORD: ${PASSWORD}"
# 创建 Hysteria2 配置文件
cat > /etc/hysteria/config.yaml <<EOF
listen: :${UDP_PORT}
tls:
cert: /etc/hysteria/server.crt
key: /etc/hysteria/server.key
auth:
type: password
password: ${PASSWORD}
masquerade:
type: proxy
proxy:
url: https://bing.com/
rewriteHost: true
EOF
# 启动 Hysteria2 到后台
/usr/local/bin/hysteria server -c /etc/hysteria/config.yaml &
# 获取公网 IP 和国家代码
SERVER_IP=$(curl -s https://api.ipify.org)
COUNTRY_CODE=$(curl -s https://ipapi.co/${SERVER_IP}/country/ || echo "XX")
echo "✅ Hysteria2 启动成功"
echo "------------------------------------------------------------------------"
echo "🎯 客户端连接配置(请将端口替换为爪云分配的外网 UDP 端口):"
echo "hy2://${PASSWORD}@${SERVER_DOMAIN}:${UDP_PORT}?sni=bing.com&insecure=1#claw.cloud-hy2-${COUNTRY_CODE}"
echo "------------------------------------------------------------------------"
# 启动 Nezha Agent,作为主进程(PID 1
exec ./nezha-agent --config /app/config.yaml
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB