latestOpenAPI 3.0.2cPanel License2026-08-106251554.3 MB

3da41671c02c

ModSecurity
Rule Settings

Return ModSecurity rules

This function retrieves the ModSecurity™ rules from one or more ModSecurity configuration files.

Important:

  • When you disable the Web Server role, the system disables this function.
  • You must include either the vendor_id or the config parameters.
get/modsec_get_rules

Query parameters

configstring

The file path to the configuration file, relative to the /usr/local/apache/conf directory.

Note:

You can use a comma-delimited list for multiple configuration files.

exclude_bare_comments1 | 0
Example:1

Whether to exclude comments that are not associated with any directives.

  • 1 — Exclude.
  • 0 — Do not exclude.
exclude_other_directives1 | 0
Example:1

Whether the function only returns the SecRule and SecAction directives from the configuration file, and comments that are not associated with a rule.

  • 1 — Only return the SecRule and SecAction directives and comments not associated with a rule.
  • 0 — Return all directives and comments.
vendor_idstring

The vendor's unique short name.

Note:

You can use a comma-delimited list for multiple vendors.

Response

HTTP Request was successful.

Example response

{
  "data": {
    "chunks": [
      {
        "config": "modsec_vendor_configs/SomeVendor/config.conf",
        "id": 662452,
        "meta_msg": "Denied dangerous config traffic",
        "rule": "SecRule REQUEST_FILENAME \"config\" \"deny,id:662452,msg:'Denied dangerous config traffic',severity:1,auditlog\"",
        "vendor_id": "SomeVendor"
      }
    ]
  },
  "metadata": {
    "command": "modsec_get_rules",
    "reason": "OK",
    "result": 1,
    "version": 1
  }
}