cPFence v4 public beta is here.

Explore v4
Enhance CP Tutorials

cPFence OLS Freeze: 100% OLS Settings Persistence for Enhance Servers

Ols Freeze conceptual feature illustration

Update: This is the original January 2025 announcement and cron-based workflow. For host-based Enhance v12, use the updated free OLS Freeze script and systemd instructions. These are standalone scripts; choose one freeze manager for a server.

We’re excited to introduce cPFence OLS Freeze, a powerful FREE script designed to help Enhance Control Panel users persist their OpenLiteSpeed (OLS) configurations across vhost rebuilds. The script preserves the saved server-level section of your OLS configuration while keeping Enhance’s current vhost section.

We’ve previously shared a guide on optimizing OpenLiteSpeed for large shared hosting servers:
How to Optimize OpenLiteSpeed for Large Shared Hosting Servers.

Since then, many Enhance admins have reached out, asking for a way to fully persist their OLS configurations, beyond the limited scope of our previous script. To address this, we created cPFence OLS Freeze—a script designed to preserve your custom server-level OLS settings on Enhance CP servers.

While we initially planned to include this feature in the paid version of cPFence, we decided to make it available for free as a way to give back to the amazing Enhance community. You’ve been incredibly supportive, and this is our way of saying thank you!


What Does cPFence OLS Freeze Do?

The cPFence OLS Freeze script is a comprehensive solution to handle the persistence of your OpenLiteSpeed settings. It works by freezing your current OLS configuration and protecting it from being overwritten during vhost rebuilds or updates triggered by Enhance CP.

Key Features:

  1. Full Configuration Persistence:
    • Preserves the saved settings before virtualhost Example {, including server-level tuning, across vhost rebuilds. Per-vhost settings remain managed by Enhance.
  2. Freeze and Unfreeze Mechanism:
    • Easily “freeze” your current settings to lock them in place.
    • “Unfreeze” when you need to make updates through the OLS admin panel, then refreeze after making changes.
  3. Automated Backup Management:
    • Backs up your OLS configuration before every freeze.
    • Automatically deletes old backups (older than 7 days) to prevent clutter.
  4. MD5 Integrity Check:
    • Checks for configuration changes on each scheduled run and restores the protected settings if the checksum differs. The checksum detects changes; it does not establish whether they were authorized.
  5. Works with Enhance CP:
    • Keeps the current vhost section when restoring the saved server settings. Test your own domain and vhost changes before relying on it in production.
  6. Compatibility with Future Enhance v12:
    • The original script included a Using_Enhance_v12 variable, set to "on" for the planned host-based layout. That was the January 2025 release context. Enhance v12 users should now follow the updated article linked above; its script uses systemd and no longer has this switch.

Installation

The steps below retain the original cron-based setup. Use administrator SSH access to the intended OLS server, keep an independent configuration backup, and test on a disposable server first. Do not install this cron job alongside the newer systemd manager.

  1. Download the Script:
    For this historical workflow, use the January 2025 revision. The main Gist now contains the newer script:
    https://gist.github.com/cPFence/041ef1ba10a41d62bd2a4d6cee2dae41
  2. Make It Executable:
    Save the script to your server (e.g., /root/cPFence_ols_freeze.sh) and make it executable:
    chmod +x /root/cPFence_ols_freeze.sh
  3. Set Up a Cron Job:
    Add a cron job to run the script every minute to monitor your configuration:
    * * * * * /root/cPFence_ols_freeze.sh >> /var/log/cPFence_ols_freeze.log 2>&1

How to Use

Here’s how to use cPFence OLS Freeze effectively. The ./ examples assume you are in the directory where you saved the script (for example, /root).

  1. Freeze Your Configuration:
    • After making changes in the OLS admin panel, freeze your settings by running:
      ./cPFence_ols_freeze.sh freeze
    • This will back up your current configuration, extract and store your OLS settings, and create an MD5 checksum to monitor future changes.
  2. Unfreeze for Edits:
    • If you need to make further changes in the OLS admin panel, unfreeze the settings first by running:
      ./cPFence_ols_freeze.sh unfreeze
    • Once unfrozen, you can stop the cron job temporarily to avoid overwriting your changes.
  3. Refreeze After Updates:
    • After completing your updates, run the freeze command again to lock in your new settings, then resume the cron job if you paused it.
  4. Automatic Enforcement:
    • When running in cron mode with no arguments, the script automatically detects changes in your configuration and reverts your settings to its frozen state if any discrepancies are found.

Important Warning!

If the configuration is frozen, it is critical to unfreeze the settings before making any changes to cPFence WAF configurations, such as enabling or disabling the WAF. Failure to unfreeze before making these changes will cause the cron job to detect changes in the configuration, resulting in a continuous loop where OpenLiteSpeed is repeatedly restarted. To avoid this, always unfreeze the configuration before modifying WAF settings, and remember to freeze it again afterward to lock in your updates. Properly following this process ensures smooth operation and avoids unnecessary interruptions.


If enforcement causes repeated restarts, unfreeze and disable the script’s cron entry before investigating. Unfreeze stops enforcement; it does not restore an earlier configuration. Keep the dated backups for recovery and review them before restoring, since an old full configuration can contain stale vhosts.

cPFence OLS Freeze vs. OLS Optimize: Which One to Choose?

Both cPFence OLS Freeze and OLS Optimize are powerful tools designed to help you manage and optimize OpenLiteSpeed configurations, but they serve different purposes:

  • cPFence OLS Freeze is ideal for administrators who want to preserve their custom server-level OLS settings through vhost rebuilds or domain updates. This script is perfect for environments where maintaining fine-tuned customizations is critical.
  • OLS Optimize, on the other hand, focuses on applying preconfigured optimizations for OpenLiteSpeed to improve performance on large shared hosting servers. It’s more suitable for environments where standardized performance improvements are prioritized over maintaining unique configurations.

If your priority is to preserve custom settings and retain full control of your OLS setup, choose cPFence OLS Freeze. If you’re looking for performance-focused optimizations without heavy customization, OLS Optimize may be the better fit.

For many scenarios, these tools can complement each other, allowing you to optimize first with OLS Optimize and then lock in those settings with cPFence OLS Freeze!


Is it Safe to Use This Script in Production?

At the time of the original January 2025 post, we’d tested this script on a couple of test servers but hadn’t deployed it in production yet, as we were still using the old OLS optimize version that met our needs. We strongly recommend conducting extensive testing in non-production environments before using this script on live servers. Be sure to thoroughly debug and test it, including scenarios like adding or removing domains, subdomains, and other configurations. If we were to deploy it in production, we’d likely run extensive tests for at least a week before making it live. The script provides a solid base, and since it’s completely free, feel free to test, debug, and adapt it to suit your needs. We would have loved to test it further ourselves, but with our current focus on other projects and priorities, we wanted to share it with the community as-is for now.

As always, exercise caution and create backups before making significant changes to your server configuration.


Closing Thoughts

With cPFence OLS Freeze, you can preserve your chosen server-level OpenLiteSpeed settings across Enhance vhost rebuilds. Keep backups, unfreeze before edits, and check the result on your own setup.

Whether you’re managing a large shared hosting environment or running a smaller setup, cPFence OLS Freeze empowers you to take complete control of your OLS configurations. It’s simple, reliable, and tailored for the Enhance community.

We’re proud to share this tool with you for free and look forward to hearing your feedback!.

Happy hosting,
The cPFence Team

Try cPFence Free for One Month

Bring server protection and monitoring together with cPFence v4+ for Enhance on Ubuntu 22.04/24.04.

Start free trial
← Back to all articles
KEEP EXPLORING
All articles