WAF Rule Builder — generate a Coraza / ModSecurity SecRule

Fill in the fields below and copy the generated rule straight into your own WAF config. Runs entirely in your browser -- nothing you enter here is sent anywhere.

Generated rule

        

This runs entirely client-side -- nothing you type is sent to ShieldIngress or anywhere else. Always review generated rules before deploying them to a live WAF.

New to these fields? Read our guide to variables, operators, and exemptions.

What the rule builder generates

The builder writes a rule in SecLang, the rule language used by ModSecurity and Coraza. You choose what part of the request to look at, how to compare it, and what to do when it matches; the builder turns that into a SecRule with the quoting and escaping already handled. It makes two kinds of rule:

What you can match on: the request URI, query string, any argument or argument name, request headers or header names, cookies, the raw request body, the full request line, the request method, uploaded file names and the client IP. Arguments, headers and cookies can be narrowed to one named field.

How you can compare: contains, equals exactly, begins with, ends with, regular expression, any of a list of phrases, IP address or CIDR range, and the built-in SQL injection and XSS detectors. Any condition can be negated with NOT, and text comparisons can ignore case.

Add more than one condition and they're joined with AND: the builder writes a chained rule, so every condition has to match.

An example

Say you want to block the WordPress login page for everyone except your office network. Two conditions do it: the request URI begins with /wp-login.php, AND the client IP is NOT in 203.0.113.0/24. With the description "Login page: office only", the builder produces:

SecRule REQUEST_URI "@beginsWith /wp-login.php" "id:1000001,phase:2,deny,status:403,msg:'Login page: office only',t:none,chain"
    SecRule REMOTE_ADDR "!@ipMatch 203.0.113.0/24" "t:none"

An exemption looks similar but runs in phase:1 with pass,nolog, and ends with ctl:ruleRemoveById=942100 (or ctl:ruleRemoveTargetById=942100;ARGS:content to skip one field), so the rule you're exempting never sees those requests. For a walk-through of each field, see writing a WAF rule with the rule builder.

Using the rule

Where it goes

Paste it into a .conf file your WAF loads, the same way your other rules are included. With ModSecurity on Apache or Nginx, or with Coraza, that's usually a custom rules file referenced from the main config. If you run the OWASP Core Rule Set (CRS), exemptions belong in a file that loads before the CRS rules (CRS ships REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf for exactly this); block rules can go before or after it.

Rule IDs

Every ID has to be unique across everything your WAF loads, or it will refuse to start. The builder won't accept IDs from 800000 to 999999, to stay clear of the range CRS uses. Pick a block of IDs for your own rules and number them from there.

Test before you block

Set the response to "Log only" first, or run the whole engine with SecRuleEngine DetectionOnly, and watch the log for a few days. If the rule only matches the traffic you meant, switch it to block. A rule that's too broad blocks real visitors, and the first you hear of it is a complaint.

Common mistakes

Frequently asked questions

Is the WAF rule builder free?
Yes. There's no account and nothing to sign up for.
Is anything I type sent to a server?
No. The rule is generated in your browser as you type. When you press Copy, the page counts that one use, but it doesn't send the rule or anything you entered.
Does it work with ModSecurity v2, ModSecurity v3 and Coraza?
Yes. The generated rules use standard SecLang that all three understand: SecRule, chained conditions, the common operators, and the ctl actions for exemptions.
Will it work alongside the OWASP Core Rule Set?
Yes. The builder keeps your rule IDs out of the CRS range, and its exemption rules are the standard way to tune a CRS rule that's blocking legitimate traffic. Load exemptions before the CRS rules.
How do I fix a false positive from a CRS rule?
Find the rule ID in your WAF log, choose "Allow / exempt", enter that ID, and add conditions for the path (and if possible the field) where it's misfiring. Skipping one field is safer than turning the rule off for the whole request.
Does it check that my rule is correct?
It checks the rule ID, that each condition has a value, that regular expressions compile and that IP addresses and CIDR ranges are valid. It can't know whether the rule matches the traffic you intend, so test it in log-only mode first.

Other free tools

Want the WAF without running it yourself?

ShieldIngress is a managed web application firewall built on Coraza and the OWASP Core Rule Set. Put your site behind it and add custom rules and exemptions like these from the portal, with bot protection, rate limiting and automatic SSL included.

Start Free Trial