xieyuanqing

Nginx Config Creator

運維安全v0.1.1
作者:xieyuanqing更新於 2026-05-18共 2 個版本 · 最新版本釋出於 2026-02-06nginx-config-creator@clawhub_xieyuanqing/nginx-config-creator
伺服器運維配置生成

據 AlphaMoat 統計,截至 2026-09,Nginx Config Creator 累計下載 3,130 次、獲 0 個星標,在全部 5,078 個 AI 技能中排名第 3,637 位,在「運維安全」分類(264 個)中排名第 238 位。

累計安裝
182
累計下載
3130
星標
-
全站排名
#3,637
全站前 72% · 「運維安全」前 91%
平台累計安裝累計下載星標評論
ClawHub ↗952935--
SkillHub ↗1823130-—

各平台的計數口徑不同,統計時間不一致。

這個技能是做什麼的

文件描述按服務名、域名和埠生成配置,測試配置後再重新載入 Web 伺服器。該操作可能修改線上配置;應先在受控環境中審閱配置並備份現有檔案。

資料釋出於 2026-10-27

可以用來做什麼

  • 為指定服務準備反向代理配置
  • 測試候選配置並檢查回滾準備

什麼時候用

  • 需要配置 Nginx/OpenResty 反向代理時
  • 在確認服務引數、目錄和備份後再處理真實伺服器時

示例提示詞

以下是根據技能文件生成的示例,不代表實際執行結果。

為這個服務草擬反向代理配置及驗證步驟,先不要修改或重新載入線上服務。

月度資料趨勢

累計下載3130
1737248532332026-03 · 累計下載 18402026-05 · 累計下載 23762026-06 · 累計下載 25182026-07 · 累計下載 27442026-08 · 累計下載 28522026-09 · 累計下載 313026-0326-09
星標-
0112026-03 · 星標 -2026-05 · 星標 -2026-06 · 星標 -2026-07 · 星標 -2026-08 · 星標 -2026-09 · 星標 -26-0326-09

2026-09 起統計方法調整:同名技能按作者分別統計,並覆蓋全部技能。圖中虛線為調整前的月份,與之後的資料不直接比較,也不計算跨越調整的增長。

月份累計下載環比星標
2026-093130—-
2026-082852+3.9%-
2026-072744+9.0%-
2026-062518+6.0%-
2026-052376—-
2026-031840—-

SKILL.md 原文

以下是作者釋出的原始檔案,按純文字顯示,本站未做修改或稽核;其中的連結不可點選,命令請核實後再執行。抓取於 2026-10-23。

3.8 KB · ClawHub v0.1.1
---
name: nginx-config-creator
description: "Creates a standard Nginx/OpenResty reverse proxy config file for a service and reloads the web server. Features safety checks and environment awareness. Takes service name, domain, and port as main arguments."
metadata:
  openclaw:
    requires:
      bins: ["bash", "docker"]
---

# Nginx Config Creator (Enterprise Grade)
展開全部(共 86 行)

This skill automates the creation of Nginx/OpenResty reverse proxy configurations. It is designed for both ease of use and safety, incorporating environment awareness and a critical safety-check mechanism.

## Features

- **Environment Awareness**: Simplifies commands by reading configuration from environment variables.
- **Safety Check**: Includes a '熔断' (fuse) mechanism. It tests the configuration before applying it and automatically rolls back if the test fails, preventing web server downtime.

## Pre-requisites (Recommended)

For maximum convenience, it is recommended to set the following environment variables on the host system:

- `NGINX_CONFIG_PATH`: The absolute path to the Nginx `conf.d` directory.
- `NGINX_CONTAINER_NAME`: The name of the running Nginx/OpenResty Docker container.

If these are not set, they **must** be provided as command-line arguments.

## Core Action: `scripts/create-and-reload.sh`

This script performs the entire operation.

### **Inputs (Command-Line Arguments)**

- `--service-name`: (Required) The short name for the service (e.g., `grafana`).
- `--domain`: (Required) The root domain name (e.g., `example.com`).
- `--port`: (Required) The local port the service is running on (e.g., `3000`).
- `--config-path`: (Optional) The path to Nginx's `conf.d` directory. **Overrides** the `NGINX_CONFIG_PATH` environment variable.
- `--container-name`: (Optional) The name of the Nginx Docker container. **Overrides** the `NGINX_CONTAINER_NAME` environment variable.

### **Output**

- **On Success**: Prints a step-by-step log of its actions and a final success message.
- **On Failure**: Prints a descriptive error message to stderr and exits. If the failure occurs during the Nginx configuration test, the full error from `nginx -t` is displayed.

### **Execution Workflow**

1.  **Parse Arguments & Environment**: The script gathers all necessary paths and names from command-line arguments and environment variables.
2.  **Generate Config**: It creates the `.conf` file in the target directory.
3.  **Test Config (Safety Check)**: It executes `nginx -t` inside the specified container.
4.  **Decide & Act**:
    - If the test passes, it proceeds to reload Nginx via `nginx -s reload`.
    - If the test fails, it **automatically deletes the generated file (rolls back)** and reports the error.
5.  **Report Result**: Informs the user of the final outcome.

### **Example Usage**

**Scenario 1: Environment variables are pre-set**

```bash
# Set for future convenience
export NGINX_CONFIG_PATH="/path/to/your/nginx/conf.d"
export NGINX_CONTAINER_NAME="your_nginx_container"

# Now, the command is very simple:
bash skills/nginx-config-creator/scripts/create-and-reload.sh \
  --service-name "grafana" \
  --domain "example.com" \
  --port "3000"
```

**Scenario 2: No environment variables (providing all info via arguments)**

```bash
bash skills/nginx-config-creator/scripts/create-and-reload.sh \
  --service-name "grafana" \
  --domain "example.com" \
  --port "3000" \
  --config-path "/path/to/your/nginx/conf.d" \
  --container-name "your_nginx_container"
```

### **Failure Strategy**

- **Missing Arguments**: The script will exit with an error if required arguments/environment variables are missing.
- **`nginx -t` Fails**: The skill is designed to be safe. It will **not** attempt to reload a broken configuration. It will clean up after itself and show you the exact error, ensuring the live web server is never affected.

「運維安全」分類下的熱門技能

資料月份:2026-09 · 下載/星標/安裝數聚合自公開技能註冊庫(ClawHub、SkillHub),按月更新。口徑說明見資料方法。