Sing-box 服务器配置生成器

为当前最主流的抗封锁协议生成 sing-box 服务端及客户端配置。

通用参数
VLESS + REALITY 参数
VLESS + WSS + ShadowTLS 参数
Hysteria 2 参数
服务器监听的端口。可以是单端口(e.g., 443)或端口范围(e.g., 30000-40000)。客户端会自动进行端口跳跃。
在使用自定义证书时,这里应填写你的域名。
如果以上两项留空,将使用自签名证书。
辅助命令
服务端配置文件 (例如: 01_reality.json)
客户端分享链接
Mihomo (Clash.Meta) 客户端配置
一键安装脚本
将此脚本粘贴到你的 Linux 服务器上以 root 用户身份运行,即可自动安装并设置 sing-box。
#!/bin/bash

# 1. Install necessary tools
echo "Installing curl, tar, and openssl..."
apt update && apt install -y curl tar openssl

# 2. Detect architecture
ARCH=$(uname -m)
case "$ARCH" in
    x86_64)
        ARCH="amd64"
        ;;
    aarch64)
        ARCH="arm64"
        ;;
    *)
        echo "Unsupported architecture: $ARCH"
        exit 1
        ;;
esac
echo "Detected architecture: $ARCH"

# 3. Get the latest version of sing-box
LATEST_VERSION=$(curl -s "https://api.github.com/repos/SagerNet/sing-box/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's/v//')
echo "Latest sing-box version: $LATEST_VERSION"
DOWNLOAD_URL="https://github.com/SagerNet/sing-box/releases/download/v${LATEST_VERSION}/sing-box-${LATEST_VERSION}-linux-${ARCH}.tar.gz"

# 4. Download and install
echo "Downloading from $DOWNLOAD_URL"
curl -sLo /tmp/sing-box.tar.gz "$DOWNLOAD_URL"
tar -xzf /tmp/sing-box.tar.gz -C /usr/local/bin --strip-components=1 "sing-box-${LATEST_VERSION}-linux-${ARCH}/sing-box"
chmod +x /usr/local/bin/sing-box
rm /tmp/sing-box.tar.gz

# 5. Create config directory
mkdir -p /etc/sing-box/

# 6. Create systemd service file
echo "Creating systemd service..."
cat > /etc/systemd/system/sing-box.service <<'EOF'
[Unit]
Description=sing-box service
After=network.target

[Service]
ExecStart=/usr/local/bin/sing-box run -D /etc/sing-box
Restart=on-failure
RestartSec=10
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target
EOF

# 7. Enable and start service
systemctl daemon-reload
systemctl enable sing-box

echo "----------------------------------------"
echo "Sing-box installation complete!"
echo "Version $(/usr/local/bin/sing-box version)"
echo ""
echo "Next steps:"
echo "1. Place your .json config files into /etc/sing-box/"
echo "2. Start the service with: systemctl start sing-box"
echo "3. Check status with: systemctl status sing-box"
echo "4. View logs with: journalctl -u sing-box -f"
echo "----------------------------------------"