mod_header

September 13, 2022 ยท View on GitHub

Introduction

mod_header modifies header of HTTP request/response based on defined rules.

Module Configuration

Description

conf/mod_header/mod_header.conf

Config ItemDescription
Basic.DataPathString
Path of rule configuration
Log.OpenDebugBoolean
Debug flag of module

Example

[Basic]
DataPath = mod_header/header_rule.data

Rule Configuration

Description

conf/mod_header/header_rule.data

Config ItemDescription
VersionString
Version of config file
ConfigStruct
Header rules for each product
Config{k}String
Product name
Config{v}Object
A ordered list of rules
Config{v}[]Object
A rule
Config{v}[].CondString
Condition expression, See Condition
Config{v}[].LastBoolean
If true, stop processing the next rule
Config{v}[].ActionsObject
A list of Actions
Config{v}[].Actions.CmdString
A Action
Config{v}[].Actions.ParamsObject
A list of parameters for action
Config{v}[].Actions.Params[]String
A parameter

Actions

ActionDescriptionParameters
REQ_HEADER_SETSet request headerHeaderName, HeaderValue
REQ_HEADER_ADDAdd request headerHeaderName, HeaderValue
REQ_HEADER_DELDelete request headerHeaderName
RSP_HEADER_SETSet response headerHeaderName, HeaderValue
RSP_HEADER_ADDAdd response headerHeaderName, HeaderValue
RSP_HEADER_DELDelete response headerHeaderName

Example

{
    "Version": "20190101000000",
    "Config": {
        "example_product": [
            {
                "cond": "req_path_prefix_in(\"/header\", false)",
                "actions": [
                    {
                        "cmd": "REQ_HEADER_SET",
                        "params": [
                            "X-Bfe-Log-Id",
                            "%bfe_log_id"
                        ]
                    },
                    {
                        "cmd": "REQ_HEADER_SET",
                        "params": [
                            "X-Bfe-Vip",
                            "%bfe_vip"
                        ]
                    },
                    {
                        "cmd": "RSP_HEADER_SET",
                        "params": [
                            "X-Proxied-By",
                            "bfe"
                        ]
                    }
                ],
                "last": true
            }
        ]
    }
}

Builtin Variables

BFE provides a list of variables which are evaluated in the runtime during the processing of each request. See the Example above.

VariableDescription
%bfe_client_ipClient IP
%bfe_client_portClient port
%bfe_request_hostValue of Request Host header
%bfe_session_idSession ID
%bfe_log_idRequest ID
%bfe_cipClient IP (CIP)
%bfe_vipVirtual IP (VIP)
%bfe_server_nameBFE instance address
%bfe_clusterBackend cluster
%bfe_backend_infoBackend information
%bfe_ssl_resumeWhether the TLS/SSL session is resumed with session id or session ticket
%bfe_ssl_cipherTLS/SSL cipher suite
%bfe_ssl_versionTLS/SSL version
%bfe_ssl_ja3_rawJA3 fingerprint string for TLS/SSL client
%bfe_ssl_ja3_hashJA3 fingerprint hash for TLS/SSL client
%bfe_http2_fingerprintHTTP/2 fingerprint
%bfe_protocolApplication level protocol
%client_cert_serial_numberSerial number of client certificate
%client_cert_subject_titleSubject title of client certificate
%client_cert_subject_common_nameSubject Common Name of client certificate
%client_cert_subject_organizationSubject Organization of client certificate
%client_cert_subject_organizational_unitSubject Organizational Unit of client certificate
%client_cert_subject_provinceSubject Province of client certificate
%client_cert_subject_countrySubject Country of client certificate
%client_cert_subject_localitySubject Locality of client certificate