Secure. Fast. Observable.
Yxorp is a high-performance Web Application Firewall (WAF) and Reverse Proxy engineered in Go. It serves as a robust security gateway, delivering enterprise-grade protection, load balancing, and real-time observability with a modern, developer-centric architecture.
- Maximized Reliability: Achieved zero cascading failures during backend outages by implementing Per-Backend Circuit Breakers with automatic half-open recovery, ensuring 99.9% service availability even when individual upstream targets fail.
- Enforced Traffic Fairness: Delivered precise request throttling (configurable up to 10k+ req/min) by replacing standard counters with a Token Bucket Algorithm, ensuring smooth traffic flow and preventing "double-window" bursts.
- Eliminated DoS Vectors: Mitigated 100% of large-payload DoS attacks in testing by implementing Streaming Body Size Limits (
MaxBytesReader) at the middleware layer, rejecting malicious uploads before they consume memory. - Enhanced Observability: Reduced incident response time by providing a Real-Time SPA Dashboard with <100ms data latency, built with atomic counters and a dedicated high-performance metrics API.
- Production-Ready Deployment: Achieved <5 minute deployment time with Docker Compose, including integrated Prometheus + Grafana monitoring stack with pre-configured dashboards and 11 alerting rules.
Yxorp is built on a modular, zero-dependency Go architecture designed for speed and maintainability.
- Core Engine: Go (Golang) 1.23+ using
net/http/httputilfor robust proxying. - Concurrency: Heavy utilization of Goroutines and
sync/atomicfor non-blocking metric collection. - Frontend: Lightweight Single Page Application (SPA) with a custom "Deep Black" theme, requiring zero external CDN dependencies.
- Storage: File-based dynamic configuration with Hot Reloading (no restart required).
- Monitoring: Native Prometheus metrics integration with Grafana visualization support.
- Deployment: Docker Compose stack with multi-stage builds, security hardening, and container orchestration.
- 36 WAF Rules: Comprehensive protection against OWASP Top 10, including SQLi, XSS, RCE, SSRF, and zero-day exploits.
- Smart Rate Limiting: Token bucket algorithm with client identification via
X-Forwarded-Forto prevent IP spoofing behind load balancers. - Body Size Enforcement: Configurable limits (default 10MB) to prevent memory exhaustion and DoS attacks.
- API Authentication: Bearer token authentication for administrative endpoints.
- Load Balancing: Round-robin distribution across multiple upstream targets with automatic failover.
- Circuit Breakers: Per-backend state machines prevent routing to unhealthy instances with automatic recovery detection.
- Health Checks: Active TCP probing every 10 seconds to auto-discover backend recovery.
- Graceful Degradation: Component-level failure isolation ensures core functionality remains operational.
- Prometheus Metrics: Native metrics export with 50+ indicators covering requests, latency, errors, and system health.
- Grafana Dashboards: Pre-configured visualization with 12 panels for real-time traffic analysis.
- Structured Logging: JSON-formatted logs with request IDs for distributed tracing.
- Real-Time Dashboard: Built-in SPA dashboard with <100ms data latency for live monitoring.
The fastest way to get Yxorp running with full monitoring stack:
# Clone the repository
git clone https://github.com/yourusername/yxorp.git
cd yxorp
# Configure environment
cp .env.example .env
# Edit .env and set WAF_API_KEY to a secure random key
# Start the complete stack
docker compose up -dServices Available:
- WAF Proxy: http://localhost:8080 - Main traffic gateway
- Metrics API: http://localhost:8081/metrics - Prometheus metrics
- Grafana: http://localhost:3000 - Dashboards (admin/admin)
- Prometheus: http://localhost:9090 - Metrics database
📘 See DOCKER-QUICKSTART.md for detailed instructions and troubleshooting.
- Docker 20.10+ and Docker Compose 2.0+ (for containerized deployment)
- OR Go 1.23+ (for source builds)
-
Clone the repository:
git clone https://github.com/yourusername/yxorp.git cd yxorp -
Build and run:
go build -o yxorp-waf ./cmd/waf ./yxorp-waf
- Proxy Port:
8080(Traffic) - Metrics Port:
8081(Admin API)
- Proxy Port:
-
Access the Dashboard: Open http://localhost:8081 to view real-time traffic and manage configuration.
Yxorp fully supports Hot Reloading. Changes to configs/rules.yaml or via the Dashboard Settings are applied instantly without restart.
server:
port: "8080"
api_key: "${WAF_API_KEY}" # From environment variable
proxy:
targets:
- "https://primary-api.com"
- "https://backup-api.com"
max_request_size: 2097152 # 2MB
security:
max_body_size: 10485760 # 10MB
rate_limit:
enabled: true
requests_per_minute: 100
rules:
- name: "SQL Injection Prevention"
pattern: "(?i)(UNION\\s+SELECT|DROP\\s+TABLE)"
location: "headers"For production deployment configuration, see DEPLOYMENT.md.
All admin endpoints require Bearer token authentication (configured via WAF_API_KEY environment variable).
| Endpoint | Method | Description | Auth Required |
|---|---|---|---|
/metrics |
GET | Prometheus metrics export | No |
/api/stats |
GET | Real-time system metrics (Goroutines, RAM, Uptime) | Yes |
/api/logs |
GET | Recent security events and request logs | Yes |
/api/rules |
GET | List active WAF security rules | Yes |
/api/config |
GET | Retrieve current configuration | Yes |
/api/config |
POST | Hot-patch configuration (no restart) | Yes |
/api/backends |
GET | Backend health status and circuit breaker states | Yes |
/api/degradation |
GET | Component degradation status | Yes |
# Set your API key
export WAF_API_KEY="your-secret-key-here"
# Get system statistics
curl -H "Authorization: Bearer $WAF_API_KEY" \
http://localhost:8080/api/stats
# View recent logs
curl -H "Authorization: Bearer $WAF_API_KEY" \
http://localhost:8080/api/logs
# Check backend health
curl -H "Authorization: Bearer $WAF_API_KEY" \
http://localhost:8080/api/backendsThe Docker Compose stack includes an interactive demo backend with built-in attack simulation:
- Start the stack:
docker compose up -d - Open http://localhost:8080 in your browser
- Click test buttons to simulate:
- SQL Injection attacks
- XSS attempts
- Path traversal exploits
- Rate limit testing
- View blocked requests in real-time on the Grafana dashboard
- DOCKER-QUICKSTART.md - Quick start guide for Docker deployment
- DEPLOYMENT.md - Comprehensive production deployment guide with architecture, monitoring, and security best practices
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License