Skip to main content

Module real_ip

Module real_ip 

Source
Expand description

The real-ip node — rewrites the client address seen by the rest of the pipeline (context.request.remote_addr) from a request variable such as http_x_forwarded_for or http_x_real_ip.

Port of APISIX’s real-ip plugin. The rewrite only happens when the direct peer address matches trusted_addresses (when configured), so a client cannot spoof its IP unless the request came through a trusted proxy. This plugin never fails at execution time: any non-match, missing header, or unparsable address is a silent passthrough.

Structs§

RealIpPlugin
Replaces context.request.remote_addr with the address carried by a configured variable, guarded by a trusted-proxy allowlist.

Functions§

parse_ip_port 🔒
Parses ip, ip:port, [v6] or [v6]:port. Returns None for unparsable addresses and out-of-range ports (0 is rejected, matching APISIX’s port validation).