Skip to content

fix: proxies going from HTTP => HTTPS: matching upstream http(s) scheme#7842

Merged
arkodg merged 13 commits intoenvoyproxy:mainfrom
andreaswachs:fix/matching-upstream-scheme
Jan 28, 2026
Merged

fix: proxies going from HTTP => HTTPS: matching upstream http(s) scheme#7842
arkodg merged 13 commits intoenvoyproxy:mainfrom
andreaswachs:fix/matching-upstream-scheme

Conversation

@andreaswachs
Copy link
Copy Markdown
Contributor

@andreaswachs andreaswachs commented Dec 30, 2025

This makes it possible to use gateways that are internally exposed to Kubernetes as an HTTP service that proxies to a strictly HTTPS service. Some HTTPS services will declare a protocol error when an HTTPS request is forwarded towards them but the HTTP2 :scheme header is still set to http.

What type of PR is this?

This fixes issues with proxying from an internally exposed HTTP proxy, that proxies to strict HTTPS services

What this PR does / why we need it:

I have found issues with a Envoy Gateway deployment that is internal to a Kubernetes cluster, exposed with an HTTP listener. It is talking to an HTTP/2 service that strictly speaks HTTPS. The :scheme meta header were being passed from the downstream source as http even though the backend were configured as HTTPS.

This remediation attempts to base the scheme of the proxied requests to match what the upstream is serving.

The same issue in spirit has been discussed before, specifically for the Envoy Proxy: envoyproxy/envoy#16255

I have tested this change in a local kind cluster hand have found it to fix my issue.

Note to reviewers: I am not well versed in this Envoy Gateway code base and I welcome any and all critique and comments. I don't have the experience to foresee the consequences of this change for users, if there are any.

Release Notes: Yes

Fixes #7979

This makes it possible to use gateways that are internally exposed to
Kubernetes as an HTTP service that proxies to a strictly HTTPS service.
Some HTTPS services will declare a protocol error when an HTTPS request
is forwarded towards them but the HTTP2 `:scheme` header is still set to
`http`.

Signed-off-by: Andreas Wachs <awa@corti.ai>
@andreaswachs andreaswachs requested a review from a team as a code owner December 30, 2025 08:56
@zirain
Copy link
Copy Markdown
Member

zirain commented Dec 30, 2025

xref: envoyproxy/envoy#33020

Example usage now:
```yaml
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
  name: match-upstream-scheme
  namespace: envoy-gateway
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: Gateway
    name: my-gateway
  upstreamScheme: MatchUpstream # or PreserveDownstream (default)
```

Signed-off-by: Andreas Wachs <awa@corti.ai>
@andreaswachs andreaswachs requested a review from jukie January 9, 2026 12:03
// +optional
UseClientProtocol *bool `json:"useClientProtocol,omitempty"`

// UpstreamScheme configures how the :scheme pseudo-header is set for requests forwarded to backends.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we use Client and Backend instead of Downstream and Upstream to match existing API

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have added a commit with renames - let me know if you like it or if there are more adjustments needed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

still using Downstream and Upstream in the Enums

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah sorry I have missed this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@arkodg would it make sense to rename the field new field clientScheme that this PR introduces on the BackendTrafficPolicy spec to scheme instead if I rename the enum values to Preserve and MatchBackend?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sure +1
cc @jukie

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've renamed the field (and also moved it to the Client Traffic Policy CR)

Signed-off-by: Andreas Wachs <awa@corti.ai>
@netlify
Copy link
Copy Markdown

netlify bot commented Jan 12, 2026

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit e3872cd
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6979976cc66f580008d52570
😎 Deploy Preview https://deploy-preview-7842--cerulean-figolla-1f9435.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.

Signed-off-by: Andreas Wachs <awa@corti.ai>
arkodg
arkodg previously approved these changes Jan 20, 2026
Copy link
Copy Markdown
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks

@arkodg arkodg requested a review from jukie January 20, 2026 00:04
@arkodg arkodg added this to the v1.7.0-rc.1 Release milestone Jan 20, 2026
@arkodg arkodg requested review from a team January 20, 2026 00:04
zirain
zirain previously approved these changes Jan 20, 2026
jukie
jukie previously approved these changes Jan 20, 2026
Signed-off-by: Isaac Wilson <10012479+jukie@users.noreply.github.com>
@jukie jukie dismissed stale reviews from zirain, arkodg, and themself via 23df9ef January 20, 2026 15:02
Signed-off-by: Isaac Wilson <10012479+jukie@users.noreply.github.com>
@jukie jukie requested review from arkodg and zirain January 20, 2026 15:05
@jukie jukie self-requested a review January 20, 2026 15:05
jukie
jukie previously approved these changes Jan 20, 2026
@jukie
Copy link
Copy Markdown
Contributor

jukie commented Jan 20, 2026

Fixed the merge conflict but needs a make gen-check @andreaswachs

Signed-off-by: Andreas Wachs <awa@corti.ai>
@andreaswachs
Copy link
Copy Markdown
Contributor Author

Fixed the merge conflict but needs a make gen-check @andreaswachs

Thank you - done!

@jukie
Copy link
Copy Markdown
Contributor

jukie commented Jan 22, 2026

Still failing @andreaswachs

Signed-off-by: Andreas Wachs <awa@corti.ai>
Signed-off-by: Andreas Wachs <andreas@wachs.email>
@andreaswachs andreaswachs force-pushed the fix/matching-upstream-scheme branch from 731a852 to 68c0919 Compare January 26, 2026 12:27
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.85%. Comparing base (2951185) to head (e3872cd).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7842      +/-   ##
==========================================
+ Coverage   73.77%   73.85%   +0.07%     
==========================================
  Files         237      237              
  Lines       35754    35763       +9     
==========================================
+ Hits        26379    26412      +33     
+ Misses       7516     7498      -18     
+ Partials     1859     1853       -6     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

jukie
jukie previously approved these changes Jan 26, 2026
@jukie jukie requested review from a team January 26, 2026 21:01
@andreaswachs
Copy link
Copy Markdown
Contributor Author

Still failing @andreaswachs

I'm sorry, I failed to run all the CI checks that I could locally. I see they are working now and thank you for the approval!

Are the Ci checks on the PR something that I can trigger myself or need it be some of you guys?

@jukie
Copy link
Copy Markdown
Contributor

jukie commented Jan 27, 2026

For first time contributors you'll need someone to approve the workflow run upon each commit but in the future they'll be automatic.

zirain
zirain previously approved these changes Jan 28, 2026
Signed-off-by: Arko Dasgupta <arkodg@users.noreply.github.com>
@arkodg arkodg dismissed stale reviews from zirain and jukie via e3872cd January 28, 2026 04:58
@arkodg arkodg merged commit f0a05ca into envoyproxy:main Jan 28, 2026
47 of 50 checks passed
@jukie
Copy link
Copy Markdown
Contributor

jukie commented Jan 28, 2026

Thanks a lot for this @andreaswachs!

SadmiB pushed a commit to SadmiB/gateway that referenced this pull request Jan 30, 2026
…me (envoyproxy#7842)

* fix(translator): matching upstream http(s) scheme

This makes it possible to use gateways that are internally exposed to
Kubernetes as an HTTP service that proxies to a strictly HTTPS service.
Some HTTPS services will declare a protocol error when an HTTPS request
is forwarded towards them but the HTTP2 `:scheme` header is still set to
`http`.

Signed-off-by: Andreas Wachs <awa@corti.ai>

* rename `UpstreamScheme` to `ClientScheme` in the public facing API

Signed-off-by: Andreas Wachs <awa@corti.ai>
Signed-off-by: Sadmi Bouhafs <sadmibouhafs@gmail.com>
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.

.NET servers reject https gRPC requests terminated to plaintext by Envoy

4 participants