uwaserver/uwas
GitHub: uwaserver/uwas
一款基于 Go 语言构建的统一 Web 应用服务器,将 Web 服务、缓存、安全防护和可视化管理面板整合进单一二进制文件,旨在替代传统的 Nginx/Apache 加 cPanel 架构。
Stars: 115 | Forks: 11
# UWAS
**统一 Web 应用服务器**
一个二进制文件搞定一切。
Apache + Nginx + Varnish + Caddy + cPanel → UWAS
Convert Nginx config to UWAS
uwas migrate apache Convert Apache config to UWAS
uwas backup Create config backup
uwas restore Restore from backup
uwas php list List detected PHP versions
uwas php start Start PHP-FPM for version
uwas install Install as systemd service
uwas uninstall Remove systemd service
uwas user list List admin users
uwas doctor System diagnostics + auto-fix
uwas help Show help
```
## 架构
```
Request Flow:
TCP → TLS (SNI routing)
→ HTTP Parse
→ Middleware Chain:
Recovery → Request ID → Security Headers → Rate Limit → Access Log
→ Virtual Host Lookup
→ Per-domain: IP ACL → Rate Limit → BasicAuth → CORS → Header Transform
→ Security Guard (blocked paths, WAF)
→ Bandwidth Check (throttle/block)
→ Rewrite Engine (mod_rewrite compatible)
→ Cache Lookup (L1 memory + L2 disk)
→ Handler:
├── Static File (ETag, Range, pre-compressed, SPA)
├── FastCGI/PHP (connection pool, CGI env)
├── Reverse Proxy (5 LB algorithms, circuit breaker)
├── WebSocket (TCP tunnel, bidirectional pipe)
└── Redirect (301/302/307/308)
→ Cache Store
→ Bandwidth Record
→ Response
```
## 项目布局
```
cmd/uwas/ → CLI entry point (19 commands)
internal/
admin/ → REST API (205+ routes) + dashboard embed + TOTP auth
alerting/ → Alert thresholds + webhook/Slack/Telegram/email notifications
analytics/ → Per-domain traffic analytics
appmanager/ → Node.js/Python/Ruby/Go process management
auth/ → Multi-user RBAC (admin/reseller/user) + session + TOTP 2FA
backup/ → Local/S3/SFTP backup + restore + scheduling
bandwidth/ → Per-domain bandwidth limits (throttle/block)
build/ → Build metadata (version, commit, date) via ldflags
cache/ → L1 memory (256-shard LRU) + L2 disk cache + ESI
cli/ → CLI framework and commands
config/ → YAML parser, validation, defaults, ByteSize/Duration types
cronjob/ → Cron job management + execution monitoring
database/ → MySQL/MariaDB management + Docker container support
deploy/ → Git clone/pull + Docker-based application deployment
dnsmanager/ → Cloudflare, Route53, Hetzner, DigitalOcean DNS CRUD
dnschecker/ → DNS record verification (A/MX/NS/TXT)
doctor/ → System diagnostics + auto-fix
filemanager/ → Web file manager (browse/edit/upload/delete)
firewall/ → UFW management via API
handler/
fastcgi/ → PHP handler, CGI environment builder
proxy/ → Reverse proxy, load balancing, WebSocket, circuit breaker
static/ → Static files, MIME, ETag, pre-compressed, SPA
install/ → System package installer task queue
logger/ → Structured logger (slog wrapper)
mcp/ → MCP server for AI management
metrics/ → Prometheus-compatible metrics
middleware/ → Chain, recovery, rate limit, gzip, CORS, WAF, bot guard
migrate/ → Nginx/Apache converter + SSH site migration + clone
monitor/ → Uptime monitoring per domain
notify/ → Webhook, Slack, Telegram, Email (SMTP) channels
pathsafe/ → Path traversal guard (symlink-resolving containment check)
phpmanager/ → PHP detect, install, start/stop, per-domain assign
rewrite/ → URL rewrite engine (Apache mod_rewrite compatible)
rlimit/ → Per-domain resource limits via Linux cgroups v2
router/ → Virtual host routing, request context
selfupdate/ → Binary self-update from GitHub releases
server/ → HTTP/HTTPS/HTTP3 server + request dispatch + log rotation
serverip/ → Server IP detection (interfaces + public IP)
services/ → systemd service management (start/stop/restart)
sftpserver/ → Built-in SFTP server (pure Go, chroot per domain)
siteuser/ → SFTP user management (chroot jail + SSH keys)
terminal/ → WebSocket-to-PTY bridge for browser-based shell
tls/ → TLS manager, ACME client, auto-renewal, cert expiry alerts
acme/ → RFC 8555 ACME protocol, JWS signing
webhook/ → Event-driven webhook delivery (11 events, HMAC, retry)
wordpress/ → WordPress install, manage, debug, permissions
pkg/
fastcgi/ → FastCGI binary protocol, connection pool
htaccess/ → .htaccess parser and converter
web/dashboard/ → React 19 SPA (38 pages, Vite + TypeScript + Tailwind)
```
## 仪表盘
UWAS 包含一个位于 `/_uwas/dashboard/` 的 38 页 React 19 仪表盘,支持暗色/亮色主题:
**站点:** Dashboard、Domains、Domain Detail、Topology、Certificates、DNS Zone Editor、WordPress、Clone/Staging、Migration、File Manager
**服务器:** PHP、PHP Config、Applications、Database、SFTP Users、Cron Jobs、Services、Packages、IP Management、Email Guide
**性能:** Cache、Metrics、Analytics、Logs
**安全:** Security、Firewall、Unknown Domains、Audit Log、Admin Users
**系统:** Config Editor、Webhooks、Backups、Terminal、Updates、Doctor、Settings
**认证:** Login(支持 2FA/TOTP)
## 比较
| 特性 | UWAS | Nginx | Caddy | Apache | cPanel |
|---------|------|-------|-------|--------|--------|
| 单一二进制文件 | 是 | 否 | 是 | 否 | 否 |
| 自动 HTTPS | 是 | 否 | 是 | 否 | 是 |
| 内置缓存 | 是 | 否 | 否 | 否 | 否 |
| PHP FastCGI | 是 | 是 | 是 | 是 | 是 |
| .htaccess 支持 | 是 | 否 | 否 | 是 | 是 |
| 负载均衡器 | 是 | 是 | 否 | 否 | 否 |
| WebSocket 代理 | 是 | 是 | 否 | 否 | 否 |
| WAF | 是 | 否 | 否 | Mod | 是 |
| 控制面板 | 是 (内置) | 否 | 否 | 否 | 是 |
| 多用户认证 | 是 | 否 | 否 | 否 | 是 |
| Webhook 事件 | 是 | 否 | 否 | 否 | 否 |
| DNS 管理 | 4 家供应商 | 否 | 否 | 否 | 是 |
| MCP / AI 原生 | 是 | 否 | 否 | 否 | 否 |
| 开源协议 | AGPL-3.0 | BSD | Apache 2.0 | Apache 2.0 | 专有 |
## 性能
在 AMD Ryzen 9 9950X3D 上使用 [hey](https://github.com/rakyll/hey) 测试:
| 场景 | 请求数/秒 | 平均延迟 |
|----------|-------------|-------------|
| 小静态文件 (14B) | **7,000** | 7.1ms |
| 4KB 静态文件 | **7,100** | 7.0ms |
| 100K 请求 @ 200 并发 | **7,254** | 27ms |
| 404 错误页 | **22,000** | 2.2ms |
| 缓存 L1 查找 (基准测试) | **75,000,000** | 31ns |
| VHost 路由 (基准测试) | **70,000,000** | 35ns |
## 部署
### Systemd
```
sudo cp init/uwas.service /etc/systemd/system/
sudo systemctl enable uwas
sudo systemctl start uwas
# 实时 config 重载 (零停机)
sudo systemctl reload uwas
```
### Docker
```
docker build -t uwas .
docker run -p 80:80 -p 443:443 -v ./uwas.yaml:/etc/uwas/uwas.yaml uwas
```
## 从 Nginx/Apache 迁移
```
# 转换现有 Nginx config
uwas migrate nginx /etc/nginx/sites-enabled/example.conf > uwas.yaml
# 转换 Apache config
uwas migrate apache /etc/apache2/sites-enabled/example.conf > uwas.yaml
# 或使用 Dashboard Migration wizard 进行完整的站点迁移 (文件 + 数据库)
```
## 开发
```
make dev # Build development binary
make test # Run all tests
make lint # Run go vet + staticcheck
make clean # Clean build artifacts
# Dashboard
cd web/dashboard && npm run build
```
## 许可证
UWAS 采用双许可模式:
- **AGPL-3.0** — 面向开源和社区使用 — [完整文本](LICENSE)
- **商业许可证** — 面向企业和专有使用 — [uwaserver.com/enterprise](https://uwaserver.com/enterprise)
## 贡献
1. 首先提出 Issue 进行讨论
2. 每个 PR 仅包含一个功能/修复
3. 需要提供测试
4. `go vet` 必须通过
标签:Apache, AppImage, AVIF, Brotli压缩, Caddy, EVTX分析, FastCGI, GNU通用公共许可证, Go语言, Gzip压缩, HTTP/3, HTTPS证书, Nginx, Node.js, OpenVAS, PHP, Python, QUIC, Ruby, URL重写, Varnish, WAF, WebP, WebSocket, Web应用防火墙, Web托管, Web服务器, 主机管理, 仪表盘, 依赖分析, 单二进制文件, 反向代理, 图片优化, 开源, 控制面板, 无后门, 日志审计, 知识库, 程序破解, 统一Web服务器, 缓存, 自动HTTPS, 请求拦截, 负载均衡, 边缘计算, 运维工具