Skip to content

Fix: Preserve inbound X-Forwarded-Proto through SetXForwarded - #1095

Closed
andersontechnetverrum wants to merge 1 commit into
fabiolb:masterfrom
Veerum:fix/preserve-x-forwarded-proto
Closed

andersontechnetverrum wants to merge 1 commit into
fabiolb:masterfrom
Veerum:fix/preserve-x-forwarded-proto

Conversation

@andersontechnetverrum

Copy link
Copy Markdown

The Director-to-Rewrite migration (827dc66) added req.SetXForwarded(), which unconditionally recomputes X-Forwarded-Proto from Fabio's own connection state. This silently discards the value addHeaders() already established (preserved from a trusted upstream, or computed otherwise), breaking deployments where a TLS-terminating load balancer sits in front of Fabio and forwards plain HTTP: the load balancer's X-Forwarded-Proto: https gets overwritten back to http, which downstream apps using it to gate Secure session cookies (e.g. express-session with proxy: true) rely on to decide whether to set the cookie at all.

Capture the inbound X-Forwarded-Proto before calling SetXForwarded and restore it afterward if present, mirroring the existing X-Forwarded-For preservation right above it.

The Director-to-Rewrite migration (827dc66) added req.SetXForwarded(),
which unconditionally recomputes X-Forwarded-Proto from Fabio's own
connection state. This silently discards the value addHeaders() already
established (preserved from a trusted upstream, or computed otherwise),
breaking deployments where a TLS-terminating load balancer sits in front
of Fabio and forwards plain HTTP: the load balancer's X-Forwarded-Proto:
https gets overwritten back to http, which downstream apps using it to
gate Secure session cookies (e.g. express-session with proxy: true) rely
on to decide whether to set the cookie at all.

Capture the inbound X-Forwarded-Proto before calling SetXForwarded and
restore it afterward if present, mirroring the existing X-Forwarded-For
preservation right above it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@andersontechnetverrum
andersontechnetverrum requested a review from a team as a code owner September 17, 2026 14:15
@andersontechnetverrum andersontechnetverrum changed the title Preserve inbound X-Forwarded-Proto through SetXForwarded Fix: Preserve inbound X-Forwarded-Proto through SetXForwarded Sep 17, 2026
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Veerum Veerum closed this by deleting the head repository Sep 17, 2026
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