Child pages
  • WHM API 1 Functions - modsec_get_config_text
Skip to end of metadata
Go to start of metadata

Description

This function retrieves a ModSecurity™ configuration file's contents.

Important:

In cPanel & WHM version 76, the WebServer role affects this function.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/modsec_get_config_text?api.version=1&config=modsec2.example.conf
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/modsec_get_config_text?api.version=1&config=modsec2.example.conf
 Command Line
whmapi1 modsec_get_config_text config=modsec2.example.conf


Notes:

  • You must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/api/whmapi1

 Output (JSON)
{
    "data": {
        "text": "SecRule%20REQUEST_URI%20"example"%20"deny%2Cid%3A123456789"%0ASecAction%20"pass%2Cauditlog%2Cid%3A444444444"n"
    },
    "metadata": {
        "version": 1,
        "reason": "OK",
        "result": 1,
        "command": "modsec_get_config_text"
    }
}
 Output (XML)
<result>
   <data>
      <text>SecRule REQUEST_URI "example" "deny:id:123456789"
SecAction "pass:auditlog:id:444444444"</text>
   </data>
   <metadata>
      <version>1</version>
      <reason>OK</reason>
      <result>1</result>
      <command>modsec_get_config_text</command>
   </metadata>
</result>


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
configstring

Required

The ModSecurity™ configuration file's name.

A valid filename.modsec2.example.conf

Returns

ReturnTypeDescriptionPossible valuesExample
textstringThe ModSecurity™ configuration file's contents.A valid string.
 Click to view...
SecRule REQUEST_URI "example" "deny:id:123456789"
SecAction "pass:auditlog:id:444444444"