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.
HTTP Request was successful.
object | |
object |
whmapi1 --output=jsonpretty \ modsec_add_rule \ config='modsec2.user.conf' \ rule='SecAction "phase:1,id:168,nolog,pass,setvar:tx.REMOTE_ADDR=/%{REMOTE_ADDR}/"'
{- "data": {
- "rule": {
- "config": null,
- "config_active": null,
- "disabled": 0,
- "duplicate": 0,
- "id": 168,
- "meta_msg": "Example rule message",
- "rule": "SecAction \\\"phase:1,id:168,nolog,pass,setvar:tx.REMOTE_ADDR=/%{REMOTE_ADDR}/\\\"",
- "staged": null,
- "vendor_active": null,
- "vendor_id": null
}
}, - "metadata": {
- "command": "modsec_add_rule",
- "reason": "OK",
- "result": 1,
- "version": 1
}
}