Skip to content

mod_errors

Introduction

mod_errors replaces error responses based on specified rules.

Module Configuration

Description

conf/mod_errors/mod_errors.conf

Config Item Description
Basic.DataPath String
Path for rule configuration
Log.OpenDebug Boolean
Whether enable debug logs
Default False

Example

[Basic]
DataPath = mod_errors/errors_rule.data

Rule Configuration

Description

Config Item Description
Version String
Version of config file
Config Object
Error rules for each product
Config{k} String
Product name
Config{v} Object
A list of error rules
Config{v}[] Object
A error rule
Config{v}[].Cond String
Condition expressio, See Condition
Config{v}[].Actions Object
Action
Config{v}[].Actions.Cmd String
Name of Action
Config{v}[].Actions.Params Object
Parameters of Action
Config{v}[].Actions.Params[] String
A Parameter

Module Actions

Action Description
RETURN Return response generated from specified static html
REDIRECT Redirect to specified location

Example

{
    "Version": "20190101000000",
    "Config": {
        "example_product": [
            {
                "Cond": "res_code_in(\"404\")",
                "Actions": [
                    {
                        "Cmd": "RETURN",
                        "Params": [
                            "200", "text/html", "../conf/mod_errors/404.html"
                        ]
                    }
                ]
            },
            {
                "Cond": "res_code_in(\"500\")",
                "Actions": [
                    {
                        "Cmd": "REDIRECT",
                        "Params": [
                            "http://example.org/error.html"
                        ]
                    }
                ]
            }
        ]
    }
}