Skip to content

Set Forwarded / X-Forwarded-For when proxying HTTP traffic #4219

@paultiplady

Description

@paultiplady

Feature Request

When the linkerd-proxy forwards an HTTP request, append a Forwarded or X-Forwarded-For header entry so that upstreams can tell where the forwarded request came from.

What problem are you trying to solve?

It's common for HTTP services to log or consider the source-IP of incoming requests. For example, for rate-limiting or auditing. Usually external Load Balancers will set the X-Forwarded-For header, and Linkerd doesn't interfere with that. However for intra-cluster traffic (east/west), there is currently no good way for meshed services to learn the real source-IP of HTTP traffic, since the Linkerd proxy rewrites the source IP to 127.0.0.1.

How should the problem be solved?

When the linkerd-proxy forwards an HTTP request, inject a Forwarded or X-Forwarded-For header.

This typically involves appending the IP to the list, if it already exists, like:

X-Forwarded-For: 1.1.1.1, 2.2.2.2

Any alternatives you've considered?

It might be desirable to pick one of those headers, or to support both. XFF is universally supported. Forwarded is not (e.g. it's not supported in Django: https://code.djangoproject.com/ticket/30729).

How would users interact with this feature?

Presumably this would be injected annotation config, something like

annotations:
  config.linkerd.io/http-proxy-header: "x-forwarded-for" | "forwarded"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions