Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jet-go
Copy link
Contributor

@jet-go jet-go commented Aug 13, 2025

Description

This PR introduces support for disabling HTTP keep-alive connections to upstream servers via a new disableKeepAlives configuration option.

Motivation and Context

By default, the HTTP transport maintains keep-alive connections to upstreams for up to 30 seconds. However, this behavior may not be ideal in all scenarios—for instance, when using a Kubernetes service as an upstream, connections can remain pinned to a single pod, preventing effective load balancing. This change enables users to disable keep-alives for upstream connections, offering improved flexibility and control over proxy behavior.

How Has This Been Tested?

  1. Set up a Kubernetes environment (e.g., using Rancher Desktop).
  2. Deploy multiple replicas of an application (upstream servers) and oauth2-proxy.
  3. Configure the Kubernetes service of the application as an "upstream" in oauth2-proxy.
  4. With keep-alives enabled, observe that requests are consistently sent to the same pod.
  5. Enable the disable-keep-alives option and observe that requests are now distributed across all pods.

Checklist:

  • My change requires a change to the documentation or CHANGELOG.
  • I have updated the documentation/CHANGELOG accordingly.
  • I have created a feature (non-master) branch for my PR.
  • I have written tests for my code changes.

@jet-go jet-go requested a review from a team as a code owner August 13, 2025 14:46
@jet-go jet-go force-pushed the feature/support-disable-keepalive branch from 413f5b5 to be69f0a Compare August 13, 2025 14:47
@tuunit tuunit force-pushed the feature/support-disable-keepalive branch from be69f0a to b33ba85 Compare August 19, 2025 05:48
tuunit
tuunit previously approved these changes Aug 19, 2025
@tuunit tuunit force-pushed the feature/support-disable-keepalive branch from b33ba85 to d687ec9 Compare August 19, 2025 05:53
@tuunit tuunit merged commit f18a0b7 into oauth2-proxy:master Aug 19, 2025
6 checks passed
@jet-go jet-go deleted the feature/support-disable-keepalive branch August 28, 2025 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants