Internet privacy

Forwarded and X-Forwarded-For: why trust matters

A reverse proxy may describe client connection metadata using forwarded headers. A request header is not automatically authoritative.

Updated

Connection peer vs header

An application sees its immediate network peer. A trusted proxy may attach original-client information to the request, depending on deployment configuration.

Untrusted input

A client can supply arbitrary HTTP headers. Trusting an unsanitized forwarded header can produce incorrect address attribution. The deployment must define which proxies are trusted and how headers are replaced or interpreted.

Privacy-conscious handling

Forwarded chains may reveal internal addresses and proxy topology. Return only information needed for a diagnostic and avoid logging full chains unnecessarily. A header inspection page cannot establish another site's proxy trust model.

Review the trusted boundary

A proxy can add forwarded connection information for an upstream application. If an application accepts arbitrary client-provided values as authoritative, they may be inaccurate. Establish the trusted proxy path and documented header handling before using forwarded values for logs or access decisions.

Step-by-step example

Understand why arbitrary client-supplied forwarding headers are not proof of an address.

  1. 01

    Draw the request path

    A request can travel through a reverse proxy before reaching an application. The direct peer seen by the application can be the proxy.

    Client
    Connection
    Trusted proxy
    Forward request
    Application
    Direct peer
    Illustration · example, not a live result
  2. 02

    Identify trusted metadata

    The application should accept address metadata only from a verified trusted proxy boundary and configured header policy. A client can supply misleading header text if the boundary does not remove or replace it.

    Trusted edge
    Validated metadata
    Client text
    Untrusted input
    Illustration · example, not a live result
  3. 03

    Read this site's limitations

    The header inspector exposes a limited safe allowlist, not raw forwarded IP headers or cookies. The local preview does not guess a visitor's public IP from an arbitrary header.

    Inspector
    Allowlisted headers
    Public IP
    Trusted edge observation
    Illustration · example, not a live result

Check your understanding

Do not use X-Forwarded-For or similar values from untrusted peers as an authentication factor.

Try this tool →

Try this

Compare the documented trusted client-IP mechanism for your own hosting environment with the actual transport peer.

HTTP request header inspector →

Technical references