Skip to content

outposts/proxy: don't negotiate HTTP/2 to upstreams - #26281

Merged
rissson merged 2 commits into
goauthentik:mainfrom
robisonjoel:fix/no-http2-to-upstreams
Sep 22, 2026
Merged

rissson merged 2 commits into
goauthentik:mainfrom
robisonjoel:fix/no-http2-to-upstreams

Conversation

@robisonjoel

@robisonjoel robisonjoel commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

AI assistance disclosure

Per AI_POLICY.md:

Tool: Claude (Anthropic), driven agentically via Claude Code.

Extent: AI-assisted throughout — reading the 2026.8.x and 2026.5.7 outpost
sources, building and deploying patched images against a live deployment, and
running the reproductions below. Every status code, log line and table entry
quoted here is real command output, not model-generated text.

Human-in-the-loop: I have read and verified this change and take
responsibility for its contents.


Details

What does this PR change?

The proxy outpost no longer negotiates HTTP/2 to upstream applications:

-    .enable_all_versions()
+    .enable_http1()

set_host(false) is deliberately left alone, so upstreams keep receiving the
client's Host header exactly as before.

Two small pre-existing bugs in the same path are fixed alongside:

  • *request.version_mut() = Version::HTTP_11 in create_proxied_request — an
    inbound HTTP/2 request would otherwise be rejected by the HTTP/1.1 pool with
    UserUnsupportedVersion.
  • the upgrade-type comparison is now case-insensitive. Protocol names are
    case-insensitive (RFC 9110 §7.8), so a backend answering Upgrade: WebSocket
    currently gets a spurious 502.

Why is this change needed?

This restores the Go outpost's behaviour. At version/2026.5.7,
internal/outpost/proxyv2/application/mode_proxy.go:

func (a *Application) getUpstreamTransport() http.RoundTripper {
    return &http.Transport{
        TLSClientConfig: &tls.Config{InsecureSkipVerify: ...},
    }
}

No ForceAttemptHTTP2 — which per net/http.Transport "conservatively disables
HTTP/2". The Go outpost never spoke HTTP/2 to upstreams. .enable_all_versions()
in the Rust port is the entire delta, and it breaks HTTP/2-capable backends in
two distinct ways.

1. Ordinary requests are malformed. The outpost forwards the client's
inbound Host while hyper derives :authority from the upstream URI. When they
differ that is malformed under RFC 9113 §8.3.1 and compliant upstreams reject
it. nginx with error_log debug names it exactly:

client sent ":authority" and "Host" headers with different values
while reading client request headers, request: "GET / HTTP/2.0"

The 400 the browser sees is the upstream's own error page, proxied back, which
makes this look like an application fault rather than an outpost one.

2. WebSocket upgrades are silently dropped. Upgrade and Connection are
connection-specific and forbidden in HTTP/2 (§8.2.2), so hyper strips them before
sending; the backend receives a plain GET, answers normally, and call() never
sees a 101. HTTP/2 has no 101 at all (§8.6).

Demonstrated with one WebSocket echo backend behind three listeners on the same
nginx — same certificate, same proxy config — differing only in negotiated
protocol, logging what arrives:

h2      (TLS, ALPN h2)         proto=HTTP/2.0 up="-"         conn="-"       status=200   WS fails
h1      (TLS, ALPN http/1.1)   proto=HTTP/1.1 up="websocket" conn="upgrade" status=101   WS works
http:// (plain, control)       proto=HTTP/1.1 up="websocket" conn="upgrade" status=101   WS works

up="-" shows the headers are absent on arrival, so the backend is not
responsible.

Keeping HTTP/2 and fixing the authority mismatch is not a small change: it means
decoupling :authority from the dial target, which hyper_util::client::legacy
cannot do — its pool key is (scheme, authority) and the connector dials that
same tuple. That is a design change, not a regression fix.

How was this tested?

On a live deployment with eight proxy providers, before and after:

Internal host Upstream Before After
https://…:8443 OPNsense / lighttpd (h2) 400 on every request serves, logged-in dashboard
https://…/ OPNsense / lighttpd (h2) 400 on every request serves
https://…:11443/ UniFi OS (h2) 400 on every request WebSocket opens, live dashboard
http://…:3000 Grafana (h1) worked unaffected
http://…:30116/ OpenSpeedTest (h1) worked unaffected

The UniFi case exercises the WebSocket path specifically: its SPA will not
populate without /api/ws/system, and it additionally requires the Origin
host to equal Host on the upgrade — which holds precisely because this PR keeps
forwarding the client's Host.

Also verified against the echo rig above that all three listeners, including the
h2-capable one, now return 101.

Linked issues

closes #25388
closes #25409
closes #25643

The Go outpost this replaced used a bare `http.Transport{TLSClientConfig: ..}`
and never set `ForceAttemptHTTP2`, which per net/http "conservatively disables
HTTP/2", so upstreams were only ever spoken to over HTTP/1.1. The Rust port's
`.enable_all_versions()` changed that, and it breaks HTTP/2-capable backends
two ways.

Ordinary requests become malformed: the outpost forwards the client's inbound
`Host` while hyper derives `:authority` from the upstream URI, and when they
differ that is malformed under RFC 9113 8.3.1, so compliant upstreams answer
400. WebSocket upgrades are silently dropped: `Upgrade` and `Connection` are
forbidden in HTTP/2 (8.2.2) so hyper strips them before sending, the backend
sees a plain GET, and no 101 ever comes back (8.6).

Keeping HTTP/2 and fixing the authority mismatch would mean decoupling
`:authority` from the dial target, which hyper_util's legacy Client cannot do:
its pool key is `(scheme, authority)` and the connector dials that same tuple.

Also fixes two pre-existing bugs in the same path: pin the proxied request to
HTTP/1.1 so an inbound HTTP/2 request is not rejected by the pool with
`UserUnsupportedVersion`, and compare upgrade tokens case-insensitively, since
protocol names are case-insensitive (RFC 9110 7.8) and a backend answering
`Upgrade: WebSocket` currently gets a spurious 502.

Adds the first tests for reverse_proxy.rs, covering the request version, that
the inbound Host is forwarded unchanged, the host_header override, hop-by-hop
removal, and the case-insensitive upgrade comparison.

closes goauthentik#25388
closes goauthentik#25409
refs goauthentik#25643

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@robisonjoel
robisonjoel requested a review from a team as a code owner September 20, 2026 17:23
@netlify

netlify Bot commented Sep 20, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 2c11b50
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6ab016a2968c990008250387
😎 Deploy Preview https://deploy-preview-26281--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.53731% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.05%. Comparing base (bafc5e1) to head (94672f6).
⚠️ Report is 27 commits behind head on main.

Files with missing lines Patch % Lines
src/outpost/proxy/reverse_proxy.rs 93.93% 4 Missing ⚠️
src/outpost/proxy/upstream.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26281      +/-   ##
==========================================
+ Coverage   92.00%   92.05%   +0.04%     
==========================================
  Files        1175     1175              
  Lines       76288    76503     +215     
  Branches     4056     4121      +65     
==========================================
+ Hits        70192    70422     +230     
+ Misses       6054     6028      -26     
- Partials       42       53      +11     
Flag Coverage Δ
conformance 33.45% <ø> (-0.05%) ⬇️
e2e 38.21% <ø> (-0.05%) ⬇️
integration 29.74% <ø> (-0.49%) ⬇️
rust 44.79% <92.53%> (+1.89%) ⬆️
unit 93.58% <ø> (+0.02%) ⬆️
unit-migrate 93.59% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@rissson rissson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

apart from a nit, the tests are not passing

Comment thread src/outpost/proxy/upstream.rs Resolved
Co-authored-by: Marc 'risson' Schmitt <[email protected]>
Signed-off-by: The Ginger <[email protected]>
@netlify

netlify Bot commented Sep 21, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit 94672f6
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6ab171beb3679f0008b77e1f
😎 Deploy Preview https://deploy-preview-26281--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@robisonjoel

Copy link
Copy Markdown
Contributor Author

apart from a nit, the tests are not passing

Looking into the tests

@robisonjoel

Copy link
Copy Markdown
Contributor Author

Anything else youd want from my end on this?

@rissson rissson self-assigned this Sep 22, 2026
@rissson rissson added area:backend backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 labels Sep 22, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in authentik Core Sep 22, 2026

@rissson rissson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

all good for me!

@rissson
rissson merged commit e630aab into goauthentik:main Sep 22, 2026
139 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in authentik Core Sep 22, 2026
@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.8 created: #26342

rissson added a commit that referenced this pull request Sep 22, 2026
… to version-2026.8) (#26342)

Co-authored-by: The Ginger <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Marc 'risson' Schmitt <[email protected]>
Signed-off-by: The Ginger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

Archived in project

2 participants