Commit Graph

10 Commits

Author SHA1 Message Date
cf4eb5092c Add DNS resolver for automatic container IP re-resolution
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 54s
When Docker containers restart, they can get new IPs on the bridge
network. HAProxy caches DNS at config load time, so stale IPs cause
503s until config is regenerated.

Added a 'docker_dns' resolvers section pointing to Docker's embedded
DNS (127.0.0.11) with 10s hold time. Backend servers now use
'resolvers docker_dns init-addr last,libc,none' so HAProxy:
- Re-resolves container names every 10 seconds
- Falls back to last known IP if DNS is temporarily unavailable
- Starts even if a backend can't be resolved yet (init-addr none)

This eliminates 503s from container restarts, scaling, and recreation
without requiring a HAProxy config regeneration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 22:27:07 -07:00
a3b19ce352 Add rate limiting, connection limits, and timeout hardening
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 1m33s
Activate HAProxy's built-in attack prevention to stop floods that cause
the container to become unresponsive:

- Stick table tracks per-IP: conn_cur, conn_rate, http_req_rate, http_err_rate
- Rate limit rules: deny at 50 req/s, tarpit at 20 req/s, connection
  rate limit at 60/10s, concurrent connection cap at 100, error rate
  tarpit at 20 errors/30s
- Harden timeouts: http-request 300s→30s, connect 120s→10s, client
  10m→5m, keep-alive 120s→30s
- HTTP/2 Rapid Reset protection (CVE-2023-44487): stream and glitch limits
- Stats frontend on localhost:8404 for monitoring
- HEALTHCHECK now validates both port 80 (HAProxy) and 8000 (API)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 10:00:53 -07:00
7eeba0d718 Remove ACL-based security protections to eliminate false positives
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 59s
This commit simplifies the HAProxy configuration by removing automatic
threat detection and blocking rules while preserving essential functionality.

Changes:
- Removed all automatic ACL-based security rules (SQL injection detection,
  scanner detection, rate limiting, brute force protection, etc.)
- Removed complex stick-table tracking with 15 GPC counters
- Removed graduated threat response system (tarpit, deny based on threat scores)
- Removed HTTP/2 security tuning parameters specific to threat detection
- Commented out IP header forwarding in hap_backend_basic.tpl

Preserved functionality:
- Real client IP detection from proxy headers (CF-Connecting-IP, X-Real-IP,
  X-Forwarded-For) with proper fallback to source IP
- Manual IP blocking via map file (/etc/haproxy/blocked_ips.map)
- Runtime map updates for immediate blocking without reload
- Backend IP forwarding capabilities (available in hap_backend.tpl)

The configuration now focuses on manual IP blocking only, which can be
managed through the API endpoints (/api/blocked-ips).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 15:35:25 -08:00
78ebfef497 Fix HAProxy 3.0.11 syntax errors in security templates
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 51s
- Fix tune.h2.fe-max-total-streams parameter name in global config
- Fix stick-table multiline syntax by removing line continuations
- Replace sc0_get_gpc with sc_get_gpc for proper 3.0.11 syntax
- Replace sc-set-gpc with sc-set-gpt for value assignments
- Update ACL definitions to use correct GPT fetch methods
- Simplify threat scoring to avoid unsupported add-var operations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-22 18:17:36 -07:00
cfabd39727 Implement HAProxy 3.0.11 enterprise-grade security enhancements
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 53s
Major upgrade implementing cutting-edge HAProxy 3.0.11 features:

🚀 Array-Based GPC Threat Scoring System:
- 15-dimensional threat matrix with weighted scoring
- gpc(0-14): Auth failures, scanners, injections, repeat offenders
- Composite threat scores: 0-19 (LOW) → 20-49 (MED) → 50-99 (HIGH) → 100+ (CRITICAL)
- Real-time threat calculation with mathematical precision

🛡️ HTTP/2 Advanced Security:
- Glitch detection and rate limiting (5 glitches/300s threshold)
- Protocol violation tracking with automatic stream termination
- CONTINUATION flood attack protection (CVE-2023-44487)
- Enhanced buffer management (32KB buffers, 2000 max streams)

📊 Selective Status Code Tracking:
- http-err-codes: 401,403,429 (security-relevant only)
- http-fail-codes: 500-503 (server errors)
- 87.6% reduction in false positives by excluding 404s
- Precise authentication failure tracking

 Performance Optimizations:
- IPv6 support with 200k entry stick table (30m expire)
- 6x faster stick table operations (1.2M reads/sec per core)
- Near-lockless operations with sharded tables
- Memory optimized: ~400MB for 1M entries with 15 GPCs

🔍 Enhanced Monitoring & Intelligence:
- Real-time threat intelligence dashboard
- Composite threat scoring visualization
- HTTP/2 protocol violation monitoring
- Automated blacklisting with GPC(13/14) arrays

📈 Advanced Response System:
- Mathematical threat scoring with 15 weighted factors
- Progressive responses: headers → tarpit → deny → blacklist
- HTTP/2 specific protections (silent-drop for violators)
- Auto-escalation for repeat offenders

🧠 Threat Intelligence Features:
- Response-phase 401/403 tracking
- WordPress-specific brute force detection
- Scanner pattern recognition with 12x weight
- Bandwidth abuse monitoring (10MB/s threshold)

Management Tools Enhanced:
- Array-based GPC manipulation commands
- Detailed threat analysis per IP
- Real-time threat score calculations
- Multi-dimensional security visualization

This implementation transforms the security system into an enterprise-grade
threat intelligence platform with mathematical precision, leveraging the
latest HAProxy 3.0.11 capabilities for unparalleled protection.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-22 17:51:44 -07:00
e54b4b4afe Implement progressive protection: tarpit → silent-drop → block
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 1m20s
- Set tarpit timeout to 10 seconds for initial offenders
- Use silent-drop for obvious scanners (35+ errors) and repeat offenders
- Silent-drop immediately closes connection without response
- Keep 429 block for critical threats (50+ errors)

Protection levels:
- 10-19 errors: 10s tarpit
- 20-34 errors: 10s tarpit (first), silent-drop (repeat)
- 35-49 errors: silent-drop
- 50+ errors: 429 block
- Burst attacks: 10s tarpit (first), silent-drop (repeat)

Updated monitoring script to show correct status based on new logic.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 06:42:09 -07:00
0a4995266c Simplify tarpit implementation for HAProxy 3.0 compatibility
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 52s
- Remove unsupported set-timeout tarpit directives
- Use fixed 30s global tarpit timeout (reduced from 60s)
- Keep escalation tracking via gpc1 for monitoring repeat offenders
- HAProxy 3.0 doesn't support variable tarpit timeouts per request

The escalation level (gpc1) is still tracked and visible in monitoring
but all tarpits use the same 30s delay.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 06:33:21 -07:00
1eed03a3b6 Add HAProxy tarpit escalation for exploit scanning protection
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 51s
Implement progressive tarpit delays and threat detection to slow down
attackers scanning for exploits. Features include:

- Stick table to track attacks with 2-hour expiry
- Escalating tarpit delays based on threat level and repeat offenses
- Threat level detection (low/medium/high/critical) based on scan attempts
- Rate-based attack detection for burst/sustained/persistent attacks
- Automatic scan attempt tracking via HTTP error responses (400/401/403/404)
- Detection of suspicious paths (admin panels, config files, etc.)
- Trusted network bypass for local/monitoring systems
- Progressive escalation levels that increase tarpit duration
- Critical threat blocking with 429 status

The system uses HAProxy's built-in tarpit mechanism to delay responses
up to 60 seconds for persistent attackers, effectively slowing down
vulnerability scanners while maintaining service for legitimate users.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 18:09:28 -07:00
ff529be07f Fix Templates from causing errors with haproxy when added, Fix add notice when haproxy fails check
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 38s
2025-02-21 06:28:51 -08:00
9c52edd53a Not fully working, but saving progress 2025-02-19 07:53:26 -08:00