← 返回
未分类

Static Webhost

Deploy static web pages and apps via Caddy or Nginx (auto-detected). Use when: 通过 Caddy 或 Nginx 部署静态网页和应用(自动检测)。使用场景: (1) User asks to create a web page, dem...
使用 Caddy 或 Nginx(自动检测)部署静态网页和应用。适用场景:用户请求创建网页、演示等。
serein-213 serein-213 来源
未分类 clawhub v1.2.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 392
下载
💾 0
安装
1
版本
#latest

概述

Static WebHost

Author: Serein-213

Deploy static files to Caddy or Nginx. Auto-detects which server is available.


⚠️ 安全警告 / Security Warning

此 skill 执行的操作需要 elevated privileges(sudo/root),属于高危操作。

权限需求

  • 写入系统目录: /var/www/html/(Web 根目录)
  • 修改配置文件: /etc/nginx//etc/caddy/Caddyfile
  • 系统服务管理: systemctl reload nginx/caddy
  • 包管理器操作: pacman -S / apt install(如需要安装 Web 服务器)

使用前必须确认

  1. 用户明确授权 — 不要自动执行,必须先向用户说明并获得确认
  2. 备份现有配置 — 修改 Web 服务器配置前务必备份
  3. 测试环境优先 — 首次使用建议在测试环境验证
  4. 了解回滚方案 — 知道如何恢复配置(备份还原、服务重启)

备份命令(执行任何修改前)

# Nginx 配置备份
sudo cp -r /etc/nginx /etc/nginx.backup.$(date +%Y%m%d_%H%M%S)

# Caddy 配置备份  
sudo cp /etc/caddy/Caddyfile /etc/caddy/Caddyfile.backup.$(date +%Y%m%d_%H%M%S)

# Web 根目录备份(如已有内容)
sudo cp -r /var/www/html /var/www/html.backup.$(date +%Y%m%d_%H%M%S)

替代方案(无需 root)

如果不需要系统级部署,考虑:

  • 用户级静态服务器:python3 -m http.server 8080
  • Node.js: npx serve ./public
  • Docker 容器化部署(隔离环境)

Step 0: Detect Web Server

Before deploying, detect which web server is installed and running:

# Check Caddy
command -v caddy && systemctl is-active caddy 2>/dev/null

# Check Nginx
command -v nginx && systemctl is-active nginx 2>/dev/null

Priority: Caddy (if both are running) > Nginx > Neither (prompt user to install one).


Caddy Deployment

Setup (first time only)

Ensure Caddyfile has a static file block. Add if missing:

:80 {
    handle_path /r/* {
        file_server {
            root /var/www/html
        }
    }
}

Then systemctl reload caddy.

Deploy

mkdir -p /var/www/html/<project-name>
cp -r <source-files> /var/www/html/<project-name>/

URL: http:///r//index.html

No reload needed — files are served instantly.


Nginx Deployment

Setup (first time only)

Create a location block in the Nginx site config (e.g. /etc/nginx/sites-available/default or /etc/nginx/conf.d/static.conf):

server {
    listen 80;
    # ... existing config ...

    location /r/ {
        alias /var/www/html/;
        autoindex off;
        try_files $uri $uri/ =404;
    }
}

Then nginx -t && systemctl reload nginx.

Deploy

mkdir -p /var/www/html/<project-name>
cp -r <source-files> /var/www/html/<project-name>/

URL: http:///r//index.html

No reload needed — files are served instantly once placed in web root.


Common Steps (both servers)

Get access URL

# Tailscale
tailscale ip -4 2>/dev/null

# Or local IP
hostname -I | awk '{print $1}'

Verify

curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:80/r/<project-name>/index.html

Expect 200.


Notes

  • Web root: /var/www/html/ (shared convention for both Caddy and Nginx)
  • URL pattern: http:///r// (consistent across both servers)
  • Files are served instantly — no reload needed after placing files
  • For subdirectories, ensure index.html exists
  • Large files (>50MB) should be considered carefully for disk usage
  • If neither Caddy nor Nginx is installed, suggest pacman -S caddy / apt install caddy / apt install nginx

版本历史

共 1 个版本

  • v1.2.0 当前
    2026-05-07 05:11 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

it-ops-security

Free Ride - Unlimited free AI

shaivpidadi
管理OpenClaw的OpenRouter免费AI模型,自动按质量排名模型,配置速率限制备用方案,并更新opencla...
★ 471 📥 78,219
it-ops-security

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 90 📥 31,005
it-ops-security

MoltGuard - Security & Antivirus & Guardrails

thomas-security
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装后可防止您和您的用户受到提示注入、数据泄露及恶意行为的侵害。
★ 116 📥 30,970