ModSecurity
Rule Settings
Add staged ModSecurity rule
This function adds a new rule to a ModSecurity™ configuration staging file. For example, if you choose to add a rule for the example.conf file, the function stages the rule in the example.conf. STAGE file.
Important:
This function does not actually deploy the rule. To deploy the rule, use the WHM API 1 Functions - modsec_deploy_all_rule_changes function.
Important:
When you disable the Web Server role, the system disables this function.
get/modsec_add_rule
Query parameters
configstring required
Example:modsec2.user.conf
The ModSecurity configuration file.
rulestring required
Example:SecAction "phase:1,id:168,nolog,pass,setvar:tx.REMOTE_ADDR=/%{REMOTE_ADDR}/"
The rule's text.
Response
HTTP Request was successful.
Example response
{
"data": {
"rule": {
"id": 168,
"meta_msg": "Example rule message",
"rule": "SecAction \\\"phase:1,id:168,nolog,pass,setvar:tx.REMOTE_ADDR=/%{REMOTE_ADDR}/\\\""
}
},
"metadata": {
"command": "modsec_add_rule",
"reason": "OK",
"result": 1,
"version": 1
}
}