WHM API.
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/
https://{host}:{port}/json-api/
Request
This function adds text to a ModSecurity™ configuration file.
Important:
When you disable the Web Server role, the system disables this function.
The ModSecurity™ configuration filename and file path, relative to the /etc/apache2/conf/ directory.
Whether to deploy the new text to the system.
1— Deploy.0— Do not deploy.
Whether to add the text as the final upload to the configuration file.
1— Final upload.0— Not the final upload.
Note:
- You must use this parameter if you wish to add the text as the final change to the configuration file.
- You must use the
initparameter with this parameter if you wish to only make one change to the configuration file.
Whether to add the text as the initial upload to the configuration file.
1— Initial upload.0— Not the initial upload.
Note:
- You must use this parameter if you wish to add the text as the initial change to the configuration file.
- You must use the
finalparameter with this parameter if you wish to only make one change to the configuration file.
- Mock server
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_assemble_config_text
- A server running WHM.
https://whm-server.tld:2087/json-api/modsec_assemble_config_text
- 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_assemble_config_text?config=modsec_vendor_configs%2Fexample.conf&deploy=1&final=1&init=1&text=newtext'{ "metadata": { "command": "modsec_assemble_config_text", "reason": "OK", "result": 1, "version": 1 } }
Request
This function adds, updates, and removes global ModSecurity™ configuration directives. The function modifies these directives in the /usr/local/apache/conf/modsec2.cpanel.conf file.
Important:
When you disable the Web Server role, the system disables this function.
This function only supports the following ModSecurity™ configuration directives:
| setting_id | Documentation |
|---|---|
| 0 | SecAuditEngine |
| 1 | SecConnEngine |
| 2 | SecRuleEngine |
| 3 | SecDisableBackendCompression |
| 4 | SecGeoLookupDb |
| 5 | SecGsbLookupDb |
| 6 | SecGuardianLog |
| 7 | SecHttpBlKey |
| 8 | SecPcreMatchLimit |
| 9 | SecPcreMatchLimitRecursion |
The configuration setting's ID.
Note:
To configure multiple IDs, increment the parameter name. For example, setting_id1, setting_id2, and setting_id3.
The configuration setting's current state.
OnOff
Some settings accept additional values for this parameter. See the references above for more inforamation.
Note:
- To configure multiple settings, increment the parameter name. For example,
state1,state2, andstate3. stateis ignored ifremoveis set to1for the setting.
Whether to add or remove the configuration setting in the /usr/local/apache/conf/modsec2.cpanel.conf file.
1— Remove the configuration setting.0— Add or update the configuration setting.To remove multiple settings, increment the parameter name. For example,
remove1,remove2, andremove3.
- Mock server
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_batch_settings
- A server running WHM.
https://whm-server.tld:2087/json-api/modsec_batch_settings
- 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_batch_settings?setting_id=9&state=On&remove=0'{ "data": { "updated_settings": [ … ] }, "metadata": { "command": "modsec_batch_settings", "reason": "OK", "result": 1, "version": 1 } }
Request
This function deploys the staged changes to your modsec2.cpanel.conf file and attempts to restart Apache. If the new settings fail validation, the system restores the /etc/apache2/conf.d/modsec/modsec2.cpanel.conf file.
Note:
Call the WHM API 1 modsec_set_setting function to prepare your changes for the modsec2.cpanel.conf 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_deploy_settings_changes
- A server running WHM.
https://whm-server.tld:2087/json-api/modsec_deploy_settings_changes
- 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_deploy_settings_changes{ "data": {}, "metadata": { "command": "modsec_deploy_settings_changes", "reason": "OK", "result": 1, "version": 1 } }