Skip to content

Web-Application Firewall and Reverse Proxy written in Go

Notifications You must be signed in to change notification settings

naveenchander30/yxorp

Repository files navigation

Yxorp

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.

🚀 Key Achievements

  • 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.

🛠 Technical Architecture

Yxorp is built on a modular, zero-dependency Go architecture designed for speed and maintainability.

  • Core Engine: Go (Golang) 1.23+ using net/http/httputil for robust proxying.
  • Concurrency: Heavy utilization of Goroutines and sync/atomic for 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.

📦 Features

Security & Compliance

  • 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-For to 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.

Reliability & Performance

  • 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.

Observability & Monitoring

  • 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.

🏁 Getting Started

Quick Start with Docker (Recommended)

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 -d

Services Available:

📘 See DOCKER-QUICKSTART.md for detailed instructions and troubleshooting.

Prerequisites

  • Docker 20.10+ and Docker Compose 2.0+ (for containerized deployment)
  • OR Go 1.23+ (for source builds)

Installation from Source

  1. Clone the repository:

    git clone https://github.com/yourusername/yxorp.git
    cd yxorp
  2. Build and run:

    go build -o yxorp-waf ./cmd/waf
    ./yxorp-waf
    • Proxy Port: 8080 (Traffic)
    • Metrics Port: 8081 (Admin API)
  3. Access the Dashboard: Open http://localhost:8081 to view real-time traffic and manage configuration.

⚙️ 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.

📊 API Reference

All admin endpoints require Bearer token authentication (configured via WAF_API_KEY environment variable).

Admin Endpoints

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

Example Usage

# 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/backends

🎯 Testing & Demo

The Docker Compose stack includes an interactive demo backend with built-in attack simulation:

  1. Start the stack: docker compose up -d
  2. Open http://localhost:8080 in your browser
  3. Click test buttons to simulate:
    • SQL Injection attacks
    • XSS attempts
    • Path traversal exploits
    • Rate limit testing
  4. View blocked requests in real-time on the Grafana dashboard

📚 Documentation

  • DOCKER-QUICKSTART.md - Quick start guide for Docker deployment
  • DEPLOYMENT.md - Comprehensive production deployment guide with architecture, monitoring, and security best practices

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📜 License

MIT License

About

Web-Application Firewall and Reverse Proxy written in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published