运行时依赖
安装命令
点击复制技能文档
NginxWebUI 管理器 通过其内置的 REST API 管理 NginxWebUI。所有 API 调用都是通过 docker exec 进入运行的 nginxwebui 容器中进行的(需要 Docker socket 访问权限)。
工作原理 通过 POST /token/getToken 使用用户名/密码进行身份验证 将令牌存储在 NGINXWEBUI_TOKEN 环境变量中(通过 --mode login 自动刷新) 所有后续调用都使用令牌在 token 头中
使用方法 身份验证 # 首次 — 获取令牌并保存到 .env python3 {{SKILL_DIR}}/scripts/manage.py --mode login
Nginx 操作 # 检查 nginx 状态 python3 {{SKILL_DIR}}/scripts/manage.py --mode status # 验证配置 python3 {{SKILL_DIR}}/scripts/manage.py --mode check # 重载 nginx python3 {{SKILL_DIR}}/scripts/manage.py --mode reload
服务器(反向代理)管理 # 列出所有服务器 python3 {{SKILL_DIR}}/scripts/manage.py --mode list-servers # 添加新的反向代理 python3 {{SKILL_DIR}}/scripts/manage.py --mode add-server \ --name "app.example.com" --listen 443 --ssl \ --pem /path/to/cert.pem --key /path/to/key.pem \ --descr "My app" # 删除服务器通过 ID 前缀 python3 {{SKILL_DIR}}/scripts/manage.py --mode delete-server --id 12345abc
位置(反向代理规则)管理 # 列出服务器的位置 python3 {{SKILL_DIR}}/scripts/manage.py --mode list-locations --server-id 12345abc # 添加位置(路径 → 目标) python3 {{SKILL_DIR}}/scripts/manage.py --mode add-location \ --server-id 12345abc \ --path /api/ \ --target http://10.0.0.5:3000 \ --descr "API 后端" # 添加带有 websocket 支持 python3 {{SKILL_DIR}}/scripts/manage.py --mode add-location \ --server-id 12345abc \ --path /ws \ --target http://10.0.0.5:3000 \ --websocket # 删除位置 python3 {{SKILL_DIR}}/scripts/manage.py --mode delete-location --id 67890def
上游(负载均衡器)管理 # 列出上游 python3 {{SKILL_DIR}}/scripts/manage.py --mode list-upstreams
环境变量 NGINXWEBUI_USER — 必需 NGINXWEBUI_PASS — 必需 NGINXWEBUI_TOKEN — 自动管理,存储在 .env 中
要求 Docker socket 可从调用环境访问 运行的 nginxwebui 容器(名称:nginxwebui) 有效的 NginxWebUI 管理员凭据,启用 API 访问