npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cloudflared-tunnel-console

v0.1.2

Published

A local web console for managed Cloudflare named tunnels.

Readme

Cloudflared Tunnel Console

本地 Web 管理台,用于查看当前设备的 Cloudflare named tunnels,并通过表单创建或修改受管隧道。

能做什么

  • 读取 cloudflared tunnel list --output json,显示 Cloudflare 账户中当前设备可见的 named tunnels、连接数和在线状态。
  • 读取 ~/.cloudflared~/.cloudflared/tunnel-console 的 YAML 配置,显示 ingress 域名和本地服务地址。
  • 创建 tunnel、添加 DNS route、写入受限配置,并创建一个 systemd --user 常驻服务。服务地址支持带路径,例如 http://127.0.0.1:3000/bridge
  • 修改单 ingress 的本地 YAML 配置,并保留文件中其他 Cloudflared 选项;由本项目创建的 tunnel 会自动重启应用新配置。多 ingress 配置仅展示,避免表单覆盖额外路由。
  • 删除 named tunnel 前需要输入精确的 tunnel 名称确认;删除会停止 connector 并删除 Cloudflare tunnel,本项目生成的配置和 user service 会一并清理。

不会返回、展示或修改 cert.pem 和 tunnel JSON 凭据内容。

前置条件

运行用户需要:

cloudflared --version
cloudflared tunnel login
systemctl --user status

cloudflared tunnel login 会打开浏览器授权页面。用于创建 DNS route 的域名必须位于该 Cloudflare 账户可管理的 zone 中。

通过 npm 安装

发布后,任意 Linux/macOS 设备可直接安装:

npm install -g cloudflared-tunnel-console
cloudflared-tunnel-console

指定监听地址和端口:

cloudflared-tunnel-console start --host 127.0.0.1 --port 8787

安装 user-level systemd 服务:

cloudflared-tunnel-console install-service

服务配置可写入 ~/.config/cloudflared-tunnel-console.env。当 HOST 不是本机回环地址时,必须同时设置 ADMIN_TOKEN

从源码启动

cd cloudflared-tunnel-console
npm run check
npm start

浏览器访问 http://127.0.0.1:8787

本项目无 npm 运行时依赖,Node.js 20 或更新版本即可。

手动登录与多设备配置

本项目不会自动打开浏览器或代替管理员登录 Cloudflare。新设备部署后,请在该设备的终端手动执行:

cloudflared tunnel login

完成授权后刷新管理台即可。若证书不在默认目录,可通过环境变量显式配置:

CLOUDFLARED_DIR=/opt/cloudflared
CLOUDFLARED_CERT=/opt/cloudflared/cert.pem

CLOUDFLARED_CERT 只用于指定证书路径,证书内容不会被管理台读取、展示或上传。

登录管理台后,页面顶部的“Cloudflare 登录与证书”设置区也可以配置这两个路径。保存后管理台会自动重启;如果目标路径还没有证书,页面会继续显示手动登录步骤和“需要手动登录”状态。

通过 cloudflared-tunnel-console install-service 安装的 user-level systemd 服务会自动重启并加载新配置。直接运行 cloudflared-tunnel-console、Docker 或其它进程管理器部署时,页面会提示你重启对应进程后生效。

如果尚未安装 cloudflared,管理台会根据检测到的 Linux 发行版显示官方安装命令,并在安装完成后继续引导登录。也可直接参考 Cloudflare 的下载说明。

从源码常驻部署

将目录放在当前用户的 home 目录或保留当前路径后执行:

chmod +x deploy/install-user-service.sh
./deploy/install-user-service.sh

随后访问 http://127.0.0.1:8787。如需在用户退出后仍运行,管理员可执行:

sudo loginctl enable-linger "$USER"

非本机访问

默认绑定回环地址,避免未经认证地暴露隧道管理能力。若确实要绑定 LAN IP 或通过反向代理访问,创建 ~/.config/cloudflared-tunnel-console.env

HOST=0.0.0.0
PORT=8787
ADMIN_TOKEN=use-a-long-random-secret

所有 API 请求必须包含 X-Admin-Token。当前界面面向本机使用,若开启令牌,应在受认证的反向代理后部署,或扩展界面以保存该请求头。

也可以使用浏览器原生 Basic Auth:

REQUIRE_AUTH=true
ADMIN_USER=admin
ADMIN_PASSWORD=use-a-long-random-password

启用后访问页面会先弹出登录框,页面内的 API 请求会自动复用该认证。

文件与权限

  • 受管 tunnel 配置:~/.cloudflared/tunnel-console/<name>.yml,权限 0600
  • 受管 user service:~/.config/systemd/user/cloudflared-tunnel-console-<name>.service
  • 创建 tunnel 仍需要管理员手动完成 Cloudflare 登录,并依赖 cert.pem 和对应 <tunnel-id>.json,它们由 cloudflared 管理。

不要用此工具暴露数据库、Docker socket、Kubernetes API 或无认证的本地管理端口。Cloudflare Tunnel 负责连通性,不替代应用层认证。

发布到 npm

发布前建议将 package.jsonname 改为你拥有的 scope,例如 @your-npm-org/cloudflared-tunnel-console,然后:

npm login
npm pack --dry-run
npm publish --access public

npm pack --dry-run 会执行语法检查,并且只打包 CLI、服务端、前端静态资源、部署模板和文档,不会包含本机凭据或 node_modules