WHM API.
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/
https://{host}:{port}/json-api/
Request
This function stages edits to a ModSecurity™ rule. The system does not save changes directly to the configuration file. Instead, it stages the changes to the configuration file's .STAGE file (for example, for the example.conf file, the system stages changes in the example.conf.STAGE file).
Important:
When you disable the Web Server role, the system disables this function.
- Mock server
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_edit_rule
- A server running WHM.
https://whm-server.tld:2087/json-api/modsec_edit_rule
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
-u <username>:<password> \
'https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_edit_rule?config=modsec_vendor_configs%2Fexample.conf&id=1234567&rule=SecAction+%22pass%2Cid%3A1234567%22'{ "data": { "rule": { … } }, "metadata": { "command": "modsec_edit_rule", "reason": "OK", "result": 1, "version": 1 } }
Request
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_idor theconfigparameters.
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.
Whether to exclude comments that are not associated with any directives.
1— Exclude.0— Do not exclude.
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 theSecRuleandSecActiondirectives and comments not associated with a rule.0— Return all directives and comments.
- Mock server
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_get_rules
- A server running WHM.
https://whm-server.tld:2087/json-api/modsec_get_rules
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
-u <username>:<password> \
'https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_get_rules?config=string&exclude_bare_comments=1&exclude_other_directives=1&vendor_id=string'{ "data": { "chunks": [ … ], "staged_changes": 0 }, "metadata": { "command": "modsec_get_rules", "reason": "OK", "result": 1, "version": 1 } }
Request
This function removes a rule from a ModSecurity™ configuration file.
Important:
When you disable the Web Server role, the system disables this function.
- Mock server
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_remove_rule
- A server running WHM.
https://whm-server.tld:2087/json-api/modsec_remove_rule
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
-u <username>:<password> \
'https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_remove_rule?config=modsec_vendor_configs%2Fexample.conf&id=1234567890'{ "data": {}, "metadata": { "command": "modsec_remove_rule", "reason": "OK", "result": 1, "version": 1 } }