Commit Graph

65 Commits

Author SHA1 Message Date
usmannasir 2e8d9d5e8e conflict fix 2025-11-09 19:34:57 +05:00
usmannasir 6b999e5c8b Fix RHEL 9 binary filenames to match server structure
RHEL 9 binaries use '-rhel' suffix instead of '-rhel9':
- openlitespeed-phpconfig-x86_64-rhel (not rhel9)
- cyberpanel_ols_x86_64_rhel.so (not rhel9.so)

Updated URLs in install and upgrade modules to use correct filenames.
2025-11-09 17:14:47 +05:00
usmannasir 7c6ce4cd72 Fix OS detection to prioritize Ubuntu/Debian check
Ubuntu systems were incorrectly being detected as rhel9. Added explicit
Ubuntu/Debian check at the beginning of detectBinarySuffix() before
checking for RHEL-based distributions.

This ensures Ubuntu and Debian systems are properly identified and use
the correct binaries from the ubuntu/ directory instead of rhel9/.
2025-11-09 17:12:23 +05:00
usmannasir 20254f467c Add support for RHEL 8 and RHEL 9 custom binaries
Update OS detection and binary distribution to support separate binaries
for AlmaLinux/RHEL 8 and 9. The new structure uses:
- rhel8/ directory for AlmaLinux/RHEL 8.x binaries
- rhel9/ directory for AlmaLinux/RHEL 9.x binaries
- ubuntu/ directory for Ubuntu/Debian binaries

Changes:
- Enhanced detectBinarySuffix() to distinguish between RHEL 8 and 9
- Updated binary URLs to use new directory structure
- Updated ModSecurity checksums for all OS variants
- Applied changes to install, upgrade, and ModSecurity modules

This ensures proper ABI compatibility by providing OS-specific builds
with correct glibc and library dependencies for each platform.
2025-11-09 12:10:43 +05:00
usmannasir 2a20d1ef12 Add ModSecurity compatibility detection for user installations
Handle the scenario where users install ModSecurity after CyberPanel is already
installed with custom OpenLiteSpeed binaries.

Problem:
- When users click "Install ModSecurity" in CyberPanel UI, the system used
  package manager (yum/apt) to install stock ModSecurity
- Stock ModSecurity is NOT ABI-compatible with custom OLS binaries
- This causes immediate server crashes (segfaults) when installed

Solution:
- Detect if custom OLS binary is already installed before installing ModSecurity
- If custom OLS detected, download compatible ModSecurity from cyberpanel.net
- If stock OLS detected, use package manager as usual

Implementation:
- isCustomOLSBinaryInstalled(): Detects custom OLS by scanning binary for markers
- detectBinarySuffix(): Determines Ubuntu vs RHEL binaries needed
- installCompatibleModSecurity(): Downloads, verifies, and installs compatible ModSecurity
- Modified installModSec(): Main entry point - routes to compatible installer if needed

User flow:
1. User with custom OLS clicks "Install ModSecurity" in UI
2. System detects custom OLS binary is installed
3. System writes "Detected custom OpenLiteSpeed binary" to install log
4. System downloads OS-specific compatible ModSecurity from cyberpanel.net
5. System verifies SHA256 checksum
6. System backs up any existing ModSecurity
7. System installs compatible version with OLS restart
8. User sees "ModSecurity Installed (ABI-compatible version).[200]"

Safety features:
- Checksum verification before installation
- Automatic backup of existing ModSecurity
- Graceful OLS restart with timeout handling
- Detailed logging to /home/cyberpanel/modSecInstallLog

This prevents server crashes when users install ModSecurity after custom OLS
binaries are already deployed.
2025-11-08 15:28:34 +05:00
usmannasir 44bc736ee7 Add ModSecurity compatibility handling for custom OLS binaries
Implement automatic detection and update of ModSecurity when upgrading to custom OpenLiteSpeed binaries.

Problem:
- Stock ModSecurity modules are NOT ABI-compatible with custom OLS binaries
- Using stock ModSecurity with custom OLS causes server crashes (segfaults)
- Custom OLS has different memory layout and function signatures
- ModSecurity must be rebuilt against custom OLS headers

Solution:
- Detect if custom OLS binary is installed (check for PHPConfig markers)
- Detect if ModSecurity is currently installed
- Automatically download and install ABI-compatible ModSecurity
- Verify checksums before installation
- Backup existing ModSecurity before replacing

Implementation:
- isCustomOLSBinaryInstalled(): Detects custom OLS by scanning binary for markers
- installCompatibleModSecurity(): Downloads OS-specific compatible ModSecurity
- handleModSecurityCompatibility(): Orchestrates the compatibility check and update
- Integrated into upgrade process after custom binary installation

Binary URLs:
- RHEL/AlmaLinux: https://cyberpanel.net/mod_security-compatible-rhel.so
- Ubuntu/Debian: https://cyberpanel.net/mod_security-compatible-ubuntu.so

Checksums:
- RHEL SHA256: db580afc431fda40d46bdae2249ac74690d9175ff6d8b1843f2837d86f8d602f
- Ubuntu SHA256: 115971fcd44b74bc7c7b097b9cec33ddcfb0fb07bb9b562ec9f4f0691c388a6b

Safety features:
- Checksum verification before installation
- Automatic backup of existing ModSecurity
- Graceful OLS restart with timeout handling
- Non-fatal errors allow upgrade to continue

This prevents server crashes for existing CyberPanel users who have ModSecurity
installed when they upgrade to custom OpenLiteSpeed binaries.
2025-11-08 15:23:59 +05:00
usmannasir 120dcd3d20 Fix n8n proxy configuration for OpenLiteSpeed compatibility
- Change N8N_HOST to 0.0.0.0 (internal bind address, not domain)
- Simplify VHost extraHeaders to ONLY set Origin header
- Remove duplicate X-Forwarded-* headers (OLS adds these automatically)
- Remove N8N_ALLOWED_ORIGINS and N8N_ALLOW_CONNECTIONS_FROM (not needed)

The key issue was duplicate X-Forwarded-Host headers. OpenLiteSpeed proxy
contexts automatically add X-Forwarded-* headers, so explicitly setting
them creates duplicates that cause n8n validation to fail.

Only the Origin header needs explicit configuration in extraHeaders.
This works with the patched OLS binary (MD5: b9c65aa2563778975d0d2361494e9d31)
that forwards Origin headers from the client.
2025-11-08 00:32:16 +05:00
usmannasir 879fce8c5b Update n8n deployment to use latest version
- Changed from pinned version 1.86.1 to latest
- Requires OpenLiteSpeed binaries with Origin header forwarding support
- Compatible with n8n 1.87.0+ which has strict Origin validation

Note: This requires the OpenLiteSpeed binary that includes the Origin
header forwarding patch in the proxy module. The patch is available
in the CyberPanel OpenLiteSpeed distribution.
2025-11-07 21:53:02 +05:00
usmannasir 8056c16365 Fix n8n deployment compatibility with OpenLiteSpeed proxy
- Pin n8n to version 1.86.1 to avoid Origin header validation issues
- Change N8N_HOST from 0.0.0.0 to domain for better compatibility
- Add N8N_PROXY_HOPS=1 to fix X-Forwarded-For errors
- Add N8N_ALLOWED_ORIGINS and N8N_ALLOW_CONNECTIONS_FROM for future compatibility
- Fix SetupN8NVhost to remove malformed Origin header setting

n8n versions 1.87.0+ introduced strict Origin header validation that is
incompatible with OpenLiteSpeed proxy (which doesn't forward Origin headers).
Version 1.86.1 works correctly with OLS and SSE push backend.
2025-11-07 21:53:02 +05:00
usmannasir f7fc75b258 Add binary verification and rollback mechanism for OLS custom binaries
Implement safety checks to verify custom OpenLiteSpeed binaries work before committing to them:

Verification checks:
- Check library dependencies with ldd to detect missing libraries
- Test binary execution with -v flag to ensure it can run
- Detect issues like wrong binary type (ubuntu vs rhel) for the OS

Rollback mechanism:
- Automatically restore original binary from backup if verification fails
- Remove incompatible custom module
- Continue installation with standard OLS if custom binary fails

This prevents installation failures and system downtime when:
- Wrong binary type is downloaded due to OS detection issues
- Library dependencies are missing
- Binary cannot execute on the target system

Changes:
- Added verifyCustomBinary() method to check dependencies and execution
- Added rollbackCustomBinary() method to restore from backup
- Updated installCustomOLSBinaries() to verify and rollback on failure
- Applied to both install/installCyberPanel.py and plogical/upgrade.py

Benefits:
- Zero downtime: System falls back to working binary automatically
- Better error reporting: Shows which libraries are missing
- Safer upgrades: Users won't be left with broken installations
2025-11-07 13:50:47 +05:00
usmannasir 39b74cb9b7 Fix OLS binary compatibility by detecting OS distribution
Add OS detection logic to download correct OpenLiteSpeed binaries based on system type:
- Ubuntu/Debian systems: Download binaries with libcrypt.so.1 (GLIBC 2.35)
- RHEL/AlmaLinux/Rocky 8+/9+: Download binaries with libcrypt.so.2 (GLIBC 2.34)

This fixes the "libcrypt.so.2: cannot open shared object file" error that occurred
when Ubuntu systems tried to use RHEL-compiled binaries.

Changes:
- Added detectBinarySuffix() method to both installCyberPanel.py and upgrade.py
- Updated binary URLs to use https://cyberpanel.net with OS-specific suffix
- Module URL: cyberpanel_ols_x86_64_{ubuntu|rhel}.so
- Binary URL: openlitespeed-phpconfig-x86_64-{ubuntu|rhel}

Binary compatibility matrix:
- Ubuntu 20.04/22.04/24.04, Debian 10+, CentOS 7 → ubuntu binaries
- AlmaLinux 8+/9+, Rocky 8+/9+, RHEL 8+/9+, OpenEuler → rhel binaries
2025-11-07 12:52:15 +05:00
usmannasir ea0ee3f771 Add custom OLS binary installation to upgrade process
- Port custom binary installation methods from install to upgrade.py
- Automatically install/upgrade custom OLS binaries during CyberPanel upgrades
- Add architecture detection, download, installation, and module configuration
- Create automatic backups before upgrading binaries
- Enable .htaccess PHP config support for existing OpenLiteSpeed installations
- Make upgrade.py fully independent from installCyberPanel.py
2025-11-06 20:40:07 +05:00
usmannasir 99b0476358 Merge branch 'v2.4.4' into stable 2025-10-27 19:54:08 +05:00
usmannasir 0100d3ea5b add aiscanner file patcher 2025-10-26 01:56:36 +05:00
usmannasir 369f6d539b Fix acme.sh not creating domain configurations in /root/.acme.sh/
Separate acme.sh certificate issuance and installation steps to ensure
domain configurations are properly stored. Previously, combining --issue
with --cert-file/--key-file/--fullchain-file in a single command caused
acme.sh to skip storing domain configs, breaking automatic renewals and
requiring manual certificate recreation for domain aliases.
2025-10-22 12:53:05 +05:00
usmannasir 4983decba5 bug fix: ssl timeout issues 2025-10-19 23:51:55 +05:00
usmannasir 9d0d5fbd35 Fix backup restore permission error and improve SFTP fallback
- Ensure /home/cyberpanel directory exists with proper permissions before download
- Set directory permissions to 755 to allow application write access
- Refactor SCP/SFTP fallback logic to work regardless of debug mode
- Add better status messages during download process
2025-10-15 04:30:43 +05:00
usmannasir 32db00d1ae Fix backup file moving to handle compressed database backups
- Check for .sql.gz files first, then fallback to .sql
- Also move .backup.json metadata files alongside compressed backups
- Maintains backward compatibility with legacy .sql backups
2025-10-15 00:56:45 +05:00
usmannasir 7864ef63c1 Remove strict exit code checking in database restore functions
- MySQL restore may return warnings that don't indicate actual failure
- Database restoration verification is handled by subsequent password operations
- Improves reliability of compressed backup restoration
2025-10-15 00:53:31 +05:00
usmannasir 10edef5d87 Fix compressed database backup verification logic
- Changed from checking exit code to verifying file existence and size
- Resolves issue where successful mysqldump was incorrectly reported as failed
- Ensures backup file is created and not empty before marking as successful
2025-10-15 00:50:55 +05:00
usmannasir cac2e09fce Enhance database backup with compression support and backward compatibility
- Added configurable compression for database backups using gzip streaming
- Implemented auto-detection in restore function for compressed and uncompressed formats
- Added performance optimizations including --single-transaction and --extended-insert
- Created configuration file for gradual feature rollout with safe defaults
- Added helper functions for checking system capabilities and configuration
- Included comprehensive test suite to verify backward compatibility
- Maintained 100% backward compatibility with existing backup infrastructure
2025-10-14 19:54:11 +05:00
usmannasir fb02243245 Improve One-Click Backup verification with multi-method approach
- Implement timestamp-based filename verification (Method 1)
- Add file size validation with 1KB minimum requirement (Method 2)
- Filter to only check today's backup directory for accuracy (Method 3)
- Add optional SHA256 checksum verification for integrity (Method 5)
- Use find command with size filter for efficient SSH verification
- Fallback to SFTP with comprehensive file validation
- Enhanced logging for all verification steps and failures
- Remove unused 'Yesterday' variable that was never used
- Prevents false positives from old backup files
- Detects corrupted/incomplete backups via size check
2025-10-14 18:49:41 +05:00
usmannasir c9b711d5bd Fix critical bug in One-Click Backup failure notification logic
- Fix inverted .find() logic that sent notifications when backups SUCCEEDED
- Add 'status': 'failed' field required by platform API
- Change HTTP to HTTPS for BackupFailedNotify endpoint
- Add comprehensive error handling and logging
- Add 30-second timeout on API requests
- Properly handle actualDomain vs site.domain.domain cases
2025-10-14 16:23:41 +05:00
usmannasir fb16f4cf56 bug fix: staging site issue 2025-09-22 13:31:20 +05:00
Master3395 17b4965816 Enhance bandwidth usage calculation with resource management
- Introduced memory and processing time limits to prevent system overload during bandwidth calculations.
- Added error handling for file operations and improved logging for better traceability.
- Implemented batch processing of log lines to manage memory usage effectively.
- Updated methods to safely parse log data and handle large files, ensuring robust performance.
- Refactored code for clarity and maintainability, including the addition of helper functions for file size and memory limit settings.
2025-09-17 00:06:58 +02:00
Master3395 1f3d5afe6a Add PhpMyAdmin access middleware and session check for user authentication
- Updated settings.py to include PhpMyAdminAccessMiddleware for enhanced access control.
- Modified phpmyadminsignin.php to check user session and redirect to the login page if not authenticated.
2025-09-15 01:39:21 +02:00
Master3395 1a82700f51 Update PHP version references and improve AlmaLinux 9 compatibility
- Changed PHP symlink from version 8.0 to 8.3 in various scripts to ensure compatibility with the latest PHP version.
- Updated documentation links in the FAQ to point to the new community support page.
- Added checks and fixes for MariaDB installation issues specific to AlmaLinux 9.
- Enhanced the installation script to support additional PHP versions and improve overall installation reliability.
2025-09-15 01:25:52 +02:00
Master3395 583680ff90 Fix monthly bandwidth for websites
Fix monthly bandwidth for websites:
https://github.com/usmannasir/cyberpanel/issues/1496
2025-09-12 10:41:11 +02:00
Master3395 41ead838ef Add sieve by default.
Add sieve by default.
2025-09-10 20:01:52 +02:00
Master3395 0c8ee38c2b Add Almalinux 10 and php 84+85
Add Almalinux 10 and php 84+85
2025-09-07 22:57:53 +02:00
usmannasir 2a9ad35d06 bug fix: php manager turning off uploads 2025-09-03 13:27:00 +05:00
usmannasir c1f742425c bug fix: imuinfy restore after upgrade 2025-09-03 12:59:55 +05:00
usmannasir 07d86ac549 bug fix: imuinfy restore after upgrade 2025-09-03 02:04:36 +05:00
usmannasir af2ff95739 bug fix: imuinfy restore after upgrade 2025-09-03 01:41:32 +05:00
usmannasir 195dac046f bug fix: imuinfy restore after upgrade 2025-09-03 01:32:06 +05:00
usmannasir f13a1b8c20 bug fix: imuinfy restore after upgrade 2025-09-03 01:19:09 +05:00
usmannasir 6d7a86fb58 bug fix: imuinfy restore after upgrade 2025-09-03 01:11:11 +05:00
usmannasir 7fbb5f9123 bug fix: imuinfy restore after upgrade 2025-09-03 01:03:37 +05:00
usmannasir 4aff5fbd3a bug fix: imuinfy restore after upgrade 2025-09-02 23:34:16 +05:00
usmannasir 9a38b98ca9 v2.4.4 release 2025-09-01 13:11:42 +05:00
usmannasir 06653ab77c ubuntu 24 ftp fix 2025-08-29 22:30:06 +05:00
usmannasir d799449849 ubuntu 24 support inside cyberpanel 2025-08-29 22:24:13 +05:00
usmannasir cd9792c941 feat: Add comprehensive recovery mechanism for damaged CyberPanel installations during upgrade
- Implement directory integrity checks to detect missing CyberPanel components
- Add automatic recovery by cloning fresh repository when essential directories are lost
- Create database credential recovery with automatic password reset capability
- Update all service configurations (FTP, PowerDNS, Postfix, Dovecot) when password is reset
- Add service restart functionality to apply new configurations
- Preserve existing configuration files during recovery process
- Handle both Ubuntu (root password) and CentOS (separate password) database configurations

This ensures upgrades can complete successfully even when /usr/local/CyberCP is completely lost.
2025-08-23 16:02:19 +05:00
usmannasir be3c66128c bug fix: postfix/dovecot on alma9 2025-08-19 18:36:48 +05:00
usmannasir 00f2565745 bug fix: https://github.com/usmannasir/cyberpanel/issues/1479#issuecomment-3185937407 2025-08-14 20:54:38 +05:00
usmannasir e6541df356 bug fix: https://github.com/usmannasir/cyberpanel/issues/1479#issuecomment-3185937407 2025-08-14 20:50:05 +05:00
usmannasir 94bd6f7b5d bug fix: upgrade missing acl file 2025-08-13 23:35:40 +05:00
usmannasir a4791035d0 Remove CSF support as it's being discontinued on August 31, 2025
- Remove CSF menu item from sidebar navigation
- Disable CSF-related URL endpoints in firewall module
- Update upgrade process to automatically remove CSF and restore firewalld
- Archive CSF template and configuration files
- Clean up CSF references in settings and upgrade scripts

CSF (ConfigServer Security & Firewall) is shutting down on August 31, 2025.
This commit removes CSF integration and ensures firewalld is restored as the
default firewall solution during upgrades.

Fixes #1473
2025-08-11 15:49:31 +05:00
usmannasir d64ccc381e bug fix: https://github.com/usmannasir/cyberpanel/issues/773 2025-08-11 00:33:25 +05:00
usmannasir 753f4f0606 Fix: Preserve new INSTALLED_APPS during upgrade by not overwriting settings.py
The issue was that restoreCriticalFiles was restoring the OLD settings.py from backup
which didn't have new apps like 'aiScanner' in INSTALLED_APPS.

Solution:
- Modified restoreCriticalFiles to skip settings.py restoration
- Keep the NEW settings.py from the fresh clone (which has aiScanner in INSTALLED_APPS)
- Only update the DATABASES section with saved credentials from backup
- This preserves all new app registrations while maintaining database connectivity

This properly fixes the RuntimeError about aiScanner.status_models.ScanStatusUpdate
not being in INSTALLED_APPS after upgrades.
2025-08-08 22:54:44 +05:00