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

Description

This function deploys the staged changes for all of the ModSecurity™ configuration files into the live configuration files. After the function deploys the configuration files, it restarts Apache. If the new configuration is invalid, the system restores the original configuration and preserves the staged changes.

Important:

In cPanel & WHM version 76 and later, when you disable the WebServer role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples


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


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/whmapi1

 Output (JSON)
 {
    "data": {
        "outcomes": [
            {
                "ok": 1,
                "config": "modsec2.user.conf"
            },
            {
                "ok": 1,
                "config": "modsec_vendor_configs/MyVendor/one.conf"
            }
        ]
    },
    "metadata": {
        "version": 1,
        "reason": "OK",
        "result": 1,
        "command": "modsec_deploy_all_rule_changes"
    }
}
 Output (XML)
  <result>
    <data>
        <outcomes>
            <ok>1</ok>
            <config>modsec2.user.conf</config>
        </outcomes>
        <outcomes>
            <ok>1</ok>
            <config>modsec_vendor_configs/MyVendor/one.conf</config>
        </outcomes>
    </data>
    <metadata>
        <version>1</version>
        <reason>OK</reason>
        <result>1</result>
        <command>modsec_deploy_all_rule_changes</command>
    </metadata>
</result>


Note:

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

Parameters

This function does not accept parameters.

Returns

ReturnTypeDescriptionPossible valuesExample
outcomesarray

An array of information about the configuration deployment.

This array includes the config, ok, and exception returns. 

config

string

The file path to the configuration file.

The function returns this value in the outcomes array. 

  • EasyApache 3 — A valid path, relative to the/usr/local/apache/conf/ directory.  
  • EasyApache 4 and cPanel & WHM version 56 or earlier — A valid path, relative to the /etc/apache2/conf.d/ directory.
  • EasyApache 4 and cPanel & WHM version 58 or later — A valid path, relative to the /etc/apache2/conf.d/modsec/ directory.
modsec_vendor_configs/MyVendor/one.conf

ok

Boolean

Whether the rule change deployment succeeded.

The function returns this value in the outcomes array. 

  • 1 — Successful deployment.
  • 0 — Unsuccessful deployment.
1

exception

string

The error message for a failed deployment.

The function returns this value in the outcomes array. 

Note:

The function only returns this output if an error occurs.

The reason for failure.
 Click to view...

 The system could not deploy changes for “modsec_vendor_configs/MyVendor/one.conf”: The system could not validate the new Apache configuration, because httpd exited with a nonzero value. Apache produced the following error: httpd: Syntax error on line 37 of /usr/local/apache/conf/httpd.conf: Syntax error on line 26 of /usr/local/apache/conf/modsec2.conf: Syntax error on line 27 of /usr/local/apache/conf/modsec2.cpanel.conf: Could not open configuration file /usr/local/apache/conf/modsec_vendor_configs/MyVendor/one.conf: No such file or directory\n\n\n

failedarray

The list of configuration files that the system could not deploy.

Note:

The function only returns this value if an error occurs.

An array of file names. modsec_vendor_configs/MyVendor/one.conf