commit 3a29308c573aa5787e1927e16620a4da37799d1b Author: vipmc838 Date: Wed Jun 4 19:36:44 2025 +0800 Add files via upload diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d951ecc --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..1ab4d07 --- /dev/null +++ b/README.md @@ -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` | 是否启用 TLS(true/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 小时内删除,不得用作任何商业用途,文字、数据及图片均有所属版权,如转载须注明来源。 +- 使用本程序必须遵守部署服务器所在地、所在国家和用户所在国家的法律法规,程序作者不对使用者任何不当行为负责。 + + diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..7a6f7c6 --- /dev/null +++ b/entrypoint.sh @@ -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 < /etc/hysteria/config.yaml <