Skip to content

Conversation

zacblazic
Copy link
Member

Overview

Adds the ability to set X-Forwarded-* headers using a priority-based approach.

Going forward, the values of X-Original-Forwarded-* headers will be used if they exist, otherwise we fall back to the previous default values.

Examples

With X-Original-Forwarded-* headers

Incoming request:

X-Forwarded-Host: www.example.com
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Ssl: off
...
X-Original-Forwarded-Host: app.example.com
X-Original-Forwarded-Port: 443
X-Original-Forwarded-Proto: https
X-Original-Forwarded-Ssl: on

Outgoing proxy request:

X-Forwarded-Host: app.sandbox.zappi.io
X-Forwarded-Port: 443
X-Forwarded-Proto: https
X-Forwarded-Ssl: on

Without X-Original-Forwarded-* headers

Incoming request:

X-Forwarded-Host: www.example.com
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Ssl: off

Outgoing proxy request:

X-Forwarded-Host: www.example.com
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Ssl: off

Prefer setting $forwarded_ with $http_x_original_forwarded headers if
they exist, otherwise fallback to $proxy_x_forwarded headers.
@zacblazic zacblazic requested a review from a team as a code owner March 28, 2025 13:05
@zacblazic zacblazic merged commit dd59693 into master Mar 28, 2025
1 check passed
@zacblazic zacblazic deleted the add-original-x-forwarded-handling branch March 28, 2025 13:26
@zacblazic zacblazic changed the title Add original-x-forwarded header handling [SRE-4642] Add original-x-forwarded header handling Mar 31, 2025
Copy link
Member

@itskingori itskingori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants