Commit Graph

57 Commits

Author SHA1 Message Date
f3569402d3 Fix HAProxy 3.0 stick-table and ACL syntax errors
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 52s
- Remove duplicate http_err_rate entries (only one period allowed)
- Simplify to single http_err_rate(10s) for burst detection
- Fix sc0_http_err_rate ACL syntax (remove period argument)
- Replace time-based sustained/persistent attack detection with counter-based thresholds
- Use gpc0 counter thresholds for sustained (>=15) and persistent (>=30) attack detection

This resolves the configuration errors in HAProxy 3.0.11 while maintaining
effective exploit scanning protection through counter-based detection.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 18:36:02 -07:00
99435ee3e0 Fix HAProxy 3.0 compatibility issues in tarpit configuration
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 50s
- Remove gpc2 from stick-table (not supported in HAProxy 3.0)
- Fix ACL syntax: Change sc_get_gpc0(0) to sc0_get_gpc0
- Fix ACL syntax: Change sc_http_err_rate(0,period) to sc0_http_err_rate(period)
- Fix ACL syntax: Change sc_get_gpc1(0) to sc0_get_gpc1
- Reorder rules to place http-request rules before use_backend rules
- Remove duplicate gpc2 increment rule

These changes ensure compatibility with HAProxy 3.0.11 while maintaining
the tarpit escalation functionality for exploit scanning protection.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 18:30:34 -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
2406d9f995 Add 403 status to blocked IP page and reload HAProxy on IP block/unblock
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 51s
- Modified /blocked-ip route to return 403 Forbidden status with HTML page
- Added HAProxy reload after adding blocked IP to ensure consistency
- Added HAProxy reload after removing blocked IP to ensure consistency
- Includes error handling for reload failures without breaking the operation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 10:06:04 -07:00
15c7f40b2e Fix bug with haproxy config for blocked address
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 52s
2025-08-22 09:48:24 -07:00
58fa6d8aba Update blocked IP handling to use custom blocked page with 403 status
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 1m17s
**Template Changes:**
- Switch from direct denial to blocked page redirect with 403 status
- Blocked IPs now see /blocked-ip page instead of generic 403 denial
- Maintains proper 403 HTTP status code for blocked requests

**Blocked Page Updates:**
- Remove contact support button to prevent misuse
- Add clear instructions on how to request unblocking
- Provide structured guidance for contacting hosting provider
- Maintain professional appearance with helpful information

**Benefits:**
- Better user experience for legitimate blocks
- Clear instructions prevent support confusion
- Maintains security while being informative
- Professional appearance reflects well on hosting providers

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 08:36:57 -07:00
7869b81f27 CRITICAL FIX: Migrate HAProxy IP blocking from ACL to map files
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 51s
**Problem Solved:**
- HAProxy ACL 64-word limit caused config parsing failures
- "too many words, truncating after word 64" error
- Complete service outage when >64 IPs were blocked
- Error: "no such ACL : 'is_blocked'" broke all traffic routing

**Solution: HAProxy Map Files (v1.6+)**
-  Unlimited IP addresses (no word limits)
-  Runtime updates without config reloads
-  Better performance (hash table vs linear search)
-  Safer config management with validation & rollback

**Technical Implementation:**

**Map File Integration:**
- `/etc/haproxy/blocked_ips.map` stores all blocked IPs
- `http-request deny status 403 if { src -f /etc/haproxy/blocked_ips.map }`
- Runtime updates: `echo "add map #0 IP" | socat stdio /var/run/haproxy.sock`

**Safety Features Added:**
- `create_backup()` - Automatic config/map backups before changes
- `validate_haproxy_config()` - Config validation before applying
- `restore_backup()` - Automatic rollback on failures
- `reload_haproxy_safely()` - Safe reload with validation pipeline

**Runtime Management:**
- `update_blocked_ips_map()` - Sync database to map file
- `add_ip_to_runtime_map()` - Immediate IP blocking without reload
- `remove_ip_from_runtime_map()` - Immediate IP unblocking

**New API Endpoints:**
- `POST /api/config/reload` - Safe config reload with rollback
- `POST /api/blocked-ips/sync` - Sync database to runtime map

**Template Changes:**
- Replaced ACL method: `acl is_blocked src IP1 IP2...` (64 limit)
- With map method: `http-request deny if { src -f blocked_ips.map }` (unlimited)

**Backwards Compatibility:**
- Existing API endpoints unchanged (GET/POST/DELETE /api/blocked-ips)
- Database schema unchanged
- Automatic migration on first config generation

**Performance Improvements:**
- O(1) hash table lookups vs O(n) linear ACL search
- No config reloads needed for IP changes
- Supports millions of IPs if needed
- Memory efficient external file storage

**Documentation:**
- Complete migration guide in MIGRATION_GUIDE.md
- Updated API documentation with new endpoints
- Runtime management examples
- Troubleshooting guide

**Production Safety:**
- All changes include automatic backup/restore
- Config validation prevents bad deployments
- Runtime updates avoid service interruption
- Comprehensive error logging and monitoring

This fixes the critical production outage caused by ACL word limits
while providing a more scalable and performant IP blocking solution.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 08:31:17 -07:00
ca37a68255 Add IP blocking functionality to HAProxy Manager
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 1m1s
- Add blocked_ips database table to store blocked IP addresses
- Implement API endpoints for IP blocking management:
  - GET /api/blocked-ips: List all blocked IPs
  - POST /api/blocked-ips: Block an IP address
  - DELETE /api/blocked-ips: Unblock an IP address
- Update HAProxy configuration generation to include blocked IP ACLs
- Create blocked IP page template for denied access
- Add comprehensive API documentation for WHP integration
- Include test script for IP blocking functionality
- Update .gitignore with Python patterns
- Add CLAUDE.md for codebase documentation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 18:32:47 -07:00
a7ce40f600 Fix server configuration templates - add proper newlines between server entries
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 40s
2025-07-13 01:21:19 -07:00
d4f54aef35 Fix HAProxy crash loop and improve startup resilience
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 36s
- Add configuration regeneration before HAProxy startup
- Add configuration validation before starting HAProxy
- Add automatic configuration regeneration if invalid config detected
- Prevent container crashes when HAProxy fails to start
- Allow container to continue running even if HAProxy is not available
- Add better error handling and logging for startup issues
2025-07-11 19:37:41 -07:00
fac6cef0db Fix HAProxy 2.6 compatibility for default backend
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 37s
- Replace http-response set-body (HAProxy 2.8+) with local server approach
- Add separate Flask server on port 8080 to serve default page
- Update default backend template to use local server instead of inline HTML
- Maintain all customization features via environment variables
- Fix JavaScript error handling for domains API response
2025-07-11 19:27:42 -07:00
27f3f8959b Add default backend page for unmatched domains
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 37s
- Add default backend template (hap_default_backend.tpl)
- Add customizable default page HTML template (default_page.html)
- Modify generate_config() to include default backend for unmatched domains
- Add environment variables for customizing default page content:
  - HAPROXY_DEFAULT_PAGE_TITLE
  - HAPROXY_DEFAULT_MAIN_MESSAGE
  - HAPROXY_DEFAULT_SECONDARY_MESSAGE
- Update README with documentation and examples
- Ensure backward compatibility with existing configurations
- Remove email contact link as requested
2025-07-11 19:10:05 -07:00
ef488a253d Add /api/certificates/request endpoint for programmatic certificate requests, update docs and add test script
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 37s
2025-07-11 17:14:01 -07:00
7b0b4c0476 Major upgrade: API key authentication, certificate renewal/download endpoints, monitoring/alerting scripts, improved logging, and documentation updates. See UPGRADE_SUMMARY.md for details.
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 43s
2025-07-11 06:24:56 -07:00
f58dbef3c5 Merge pull request 'Update Cron' (#2) from update-cron into main
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 1m47s
Reviewed-on: #2
2025-05-30 18:16:47 +00:00
ac32141b34 Update Cron
Simplify Cron Process to reduce the possibility of it to hang when running
2025-05-30 11:16:12 -07:00
bbd6a0c22c Update README
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 48s
Updated README.md to include ways to protect port 8000
2025-05-30 00:03:17 +00:00
71b8085fb4 Merge pull request 'Fixing reload issue' (#1) from fix-reload into main
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 38s
Reviewed-on: #1
2025-04-18 23:53:17 +00:00
7550df9890 Fixing reload issue 2025-04-18 16:52:57 -07:00
8ae1a6b99f debug reload
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 1m9s
2025-03-09 11:56:18 -07:00
9de12c72de added missing return
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 58s
2025-03-09 11:11:35 -07:00
cb58f1d762 Switch reload from post to get
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 35s
2025-03-09 11:07:21 -07:00
2492eab708 Fix missing '/'
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 35s
2025-03-09 11:02:20 -07:00
64c707317f Adding reload function and more tweaks for backends
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 48s
2025-03-09 10:59:03 -07:00
7e53ba00d8 update again for GET Method
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 38s
2025-03-07 19:29:20 -08:00
2c66b1bf40 fix method to GET instead of POST
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 36s
2025-03-07 19:13:41 -08:00
edaefd9cd1 remove the extra lines at the end of the index
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 35s
2025-03-07 19:09:51 -08:00
d3dd69cc02 Adding config regenerate
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 37s
2025-03-07 19:06:38 -08:00
c27f7fb5e8 Adding httpchk options
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 37s
2025-03-07 17:19:22 -08:00
748ae8a4b7 Updating README.md to include web interface
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 37s
2025-03-07 15:57:56 -08:00
7b1e8a9536 Fix issue where backend was not getting created
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 1m39s
2025-03-06 21:03:08 -08:00
6f395fa621 fix issue with existing domains and new domains conflicting
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 38s
2025-03-06 17:45:02 -08:00
94f9223bc7 troubleshoot errors with web interface
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 39s
2025-03-06 17:14:42 -08:00
9621786175 Adding web interface
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 1m18s
2025-03-06 16:51:29 -08:00
de2957fcd2 Update README.md for changes to script
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 39s
2025-02-21 10:29:31 -08:00
c5f29374e1 Fix Template Override
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 38s
2025-02-21 10:17:15 -08:00
d944a75fb5 fix backend creation
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 39s
2025-02-21 08:28:56 -08:00
ac40737fd7 Adding template overrides
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 38s
2025-02-21 08:07:58 -08:00
6b28c118de Adding template overrides
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 38s
2025-02-21 08:01:16 -08:00
c47118729f add new line at the end of the server block to prevent issue with haproxy reloading
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 38s
2025-02-21 06:42:30 -08: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
c951103b3b adding function on start up
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 39s
2025-02-21 06:00:37 -08:00
0357a73770 cleanup template
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 37s
2025-02-20 17:13:25 -08:00
1df58758b5 Make haproxy start with the script
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 39s
2025-02-20 17:00:28 -08:00
673265690a fix file name error
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 38s
2025-02-20 16:32:07 -08:00
32498f1a04 fix order of acls and backends, put db in volume
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 38s
2025-02-20 16:26:27 -08:00
f51498a3b2 Fix Docker command
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 39s
2025-02-20 15:41:38 -08:00
ff46f0a616 Add regenerate endpoint
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 38s
2025-02-20 15:40:32 -08:00
576666d9da Fixing order for haproxy config
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 39s
2025-02-20 15:29:42 -08:00
b834a3c484 Update workflow
All checks were successful
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 39s
2025-02-20 14:46:30 -08:00