ModSecurity with the OWASP Core Rule Set on OpenLiteSpeed
5 min read
OpenLiteSpeed has its own ModSecurity module. How to install it with the current OWASP CRS 4, where the logs are, how to turn it on for one virtual host only, and what differs from nginx. Tested on Ubuntu 26.04.
OpenLiteSpeed can run the same web application firewall as nginx: the ModSecurity 3 engine with the OWASP Core Rule Set (CRS). The rules are identical. What differs is how the module is installed, how it is configured, and where the logs go.
We ran every command here on a fresh Ubuntu 26.04.1 system with OpenLiteSpeed 1.9.4 on 12 November 2026.
In short
- The module is a separate package:
ols-modsecurity, from LiteSpeed's repository. - CRS is not included. Download the current release (4.30.0) from the CRS project.
- The module is configured in
httpd_config.confwith amodule mod_security { … }block. - Blocked requests are logged in OpenLiteSpeed's own
error.log, not in a separate ModSecurity error log. - Start with
SecRuleEngine DetectionOnly, switch toOnwhen the log is clean.
1. Install the module
With LiteSpeed's repository already set up (it is, if you installed OpenLiteSpeed from it):
sudo apt-get install ols-modsecurity
ls /usr/local/lsws/modules | grep security
mod_security.so
On our system both packages were version 1.9.4-3+resolute. The module follows the server's version, so update them together.
2. Get the rules
sudo mkdir -p /usr/local/lsws/conf/modsec && cd /usr/local/lsws/conf/modsec
V=4.30.0
sudo curl -sLO https://github.com/coreruleset/coreruleset/releases/download/v$V/coreruleset-$V-minimal.tar.gz
sha256sum coreruleset-$V-minimal.tar.gz
3d678a41fd5aade34760127fef5dd64fd7a77848913fc0f70dde0cf467c94427 coreruleset-4.30.0-minimal.tar.gz
sudo tar -xzf coreruleset-$V-minimal.tar.gz
sudo cp coreruleset-$V/crs-setup.conf.example crs-setup.conf
Unlike the nginx package on Ubuntu, ols-modsecurity does not give you a base modsecurity.conf. Take the recommended one from the ModSecurity project:
sudo curl -sLo modsecurity.conf https://raw.githubusercontent.com/owasp-modsecurity/ModSecurity/v3/master/modsecurity.conf-recommended
sudo curl -sLo unicode.mapping https://raw.githubusercontent.com/owasp-modsecurity/ModSecurity/v3/master/unicode.mapping
Point the audit log to OpenLiteSpeed's log directory. In modsecurity.conf:
SecAuditLog /usr/local/lsws/logs/modsec_audit.log
Then create main.conf in the same directory:
Include /usr/local/lsws/conf/modsec/modsecurity.conf
Include /usr/local/lsws/conf/modsec/crs-setup.conf
Include /usr/local/lsws/conf/modsec/coreruleset-4.30.0/rules/*.conf
3. Load the module
Add to /usr/local/lsws/conf/httpd_config.conf:
module mod_security {
modsecurity on
modsecurity_rules_file /usr/local/lsws/conf/modsec/main.conf
ls_enabled 1
}
and restart:
sudo /usr/local/lsws/bin/lswsctrl restart
ls_enabled 1 at the server level turns the WAF on for every virtual host.
4. Detection mode first
The recommended configuration starts with SecRuleEngine DetectionOnly: requests are checked and logged, nothing is blocked.
curl -s -o /dev/null -w '%{http_code}\n' "http://127.0.0.1:8088/?id=1%27%20OR%20%271%27=%271"
200
The match is in /usr/local/lsws/logs/modsec_audit.log. Leave the site like this for about a week of real use, and note every normal action that shows up in the log.
5. Switch to blocking
In modsecurity.conf set:
SecRuleEngine On
and restart OpenLiteSpeed. On our system:
| Request | Answer |
|---|---|
| Normal page | 200 |
?id=1' OR '1'='1 (SQL injection) |
403 |
?q=<script>alert(1)</script> (XSS) |
403 |
Where the block is logged
This is the part that differs most from nginx. OpenLiteSpeed writes ModSecurity's messages into its own error.log, at the INFO level, with the virtual host's name:
[INFO] [127.0.0.1:56976#Example] [Module:mod_security]Intervention status code triggered: 403
[INFO] [127.0.0.1:56976#Example] [Module:mod_security]Log Message: [client 127.0.0.1] ModSecurity: Access denied with code 403 (phase 2). Matched "Operator `Ge' with parameter `5' against variable `TX:BLOCKING_INBOUND_ANOMALY_SCORE' (Value: `20' ) [file ".../REQUEST-949-BLOCKING-EVALUATION.conf"] [id "949110"]
Two things follow:
- If the server's log level is above
INFO, you do not see these lines. Keep the audit log on. - Rule 949110 is the rule that adds up the score and blocks. The rules that found the problem are the
Warninglines just before it. For how the score works, see ModSecurity with the OWASP CRS on nginx.
One virtual host only
To protect some sites and not others, load the rules at the server level but leave them off:
module mod_security {
modsecurity on
modsecurity_rules_file /usr/local/lsws/conf/modsec/main.conf
ls_enabled 0
}
and turn the module on in the virtual host's own configuration:
module mod_security {
ls_enabled 1
}
A virtual host can also carry its own rules. To keep one site in detection mode while the others block:
module mod_security {
ls_enabled 1
modsecurity_rules `
SecRuleEngine DetectionOnly
`
}
This is the layout Zefily uses on OpenLiteSpeed servers: rules loaded once, each site switched on in its own virtual host.
False positives
Exclusions work exactly as on nginx, because the engine is the same. Put them in a file and include it in main.conf before the CRS rules:
SecRule REQUEST_URI "@beginsWith /admin/editor" \
"id:1000,phase:1,pass,nolog,ctl:ruleRemoveTargetById=942100;ARGS:id"
Keep exclusions narrow: one rule, one parameter, one path.
Updates
ols-modsecurity and openlitespeed are separate packages with the same version number. Update them in one step, so the module always matches the server.
With Zefily
On a Zefily server with OpenLiteSpeed, Install WAF in the web stack installs the module and the pinned, checksum-verified CRS release. Each site then chooses Off, Detect only or Block on its own page. See Access, caching and protection.
Not sure which web server to use? See nginx or OpenLiteSpeed.
Frequently asked questions
Does OpenLiteSpeed support ModSecurity?
Yes. The ols-modsecurity package adds the mod_security module, which runs the ModSecurity 3 engine and can load the OWASP Core Rule Set.
Where are ModSecurity logs on OpenLiteSpeed?
Blocks are written to OpenLiteSpeed's error.log at the INFO level. The detailed audit log is wherever SecAuditLog points, for example /usr/local/lsws/logs/modsec_audit.log.
Can I enable ModSecurity for one OpenLiteSpeed virtual host only?
Yes. Load the rules at the server level with ls_enabled 0, and set ls_enabled 1 in the module block of the virtual host you want to protect.
Which OWASP CRS version works with OpenLiteSpeed?
We tested CRS 4.30.0 with OpenLiteSpeed 1.9.4 and its ModSecurity module on Ubuntu 26.04. Detection and blocking both worked.
Is the configuration the same as on nginx?
The rules and exclusions are the same. The module is loaded in httpd_config.conf instead of an nginx server block, and messages go to OpenLiteSpeed's own log.
See Web stack for the web servers Zefily installs.