Skip to main content

Module referer_restriction

Module referer_restriction 

Source
Expand description

Referer allow/deny list plugin (referer-restriction).

Port of APISIX’s referer-restriction: parses the host out of the Referer request header and matches it against a whitelist or blacklist of host patterns (exact hosts or leading-* wildcards). Rejections are routed through the node’s error port with error code REFERER_RESTRICTED.

Structs§

HostMatcher 🔒
Pre-split host patterns: exact hosts and *-prefix wildcard suffixes (mirrors APISIX’s create_host_matcher).
RefererRestrictionPlugin
Restricts access based on the host of the Referer request header.

Functions§

parse_host_list 🔒
Parses a config key as an array of host patterns. Patterns starting with * become suffix matches on the remainder; others are exact (lowercased).
referer_host 🔒
Extracts the lowercased host from a Referer value. Only http/https URLs parse (APISIX http.parse_uri parity); anything else — including a bare host without a scheme — is treated as malformed and returns None.