Skip to main content

process_upstream_substitution

Function process_upstream_substitution 

Source
pub fn process_upstream_substitution<B>(
    value: &str,
    req: &Request<B>,
    upstream_host: &str,
    request_uri: &str,
    remote_ip: &str,
) -> Result<String>
Expand description

Process header value substitutions for upstream (header_up) operations.

Supports all the placeholders of process_header_substitution plus three extra placeholders that only make sense for outbound (upstream) headers:

  • {upstream_host} — hostname:port of the reverse_proxy backend
  • {request.uri} — the full path + query of the incoming request
  • {remote_ip} — client IP from remote_addr (or X-Forwarded-For / X-Real-IP)

The order of substitution is: base placeholders first ({header.*}, {env.*}, {uuid}), then the upstream-specific ones. This lets you write e.g. header_up Host {upstream_host} while still being able to use {header.X-Foo}.