You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-12-01 22:51:45 +02:00
feat: allow disable-keep-alives configuration in upstream (#3156)
Signed-off-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
@@ -166,6 +166,10 @@ func newReverseProxy(target *url.URL, upstream options.Upstream, errorHandler Pr
|
||||
proxy.ErrorHandler = errorHandler
|
||||
}
|
||||
|
||||
// Pass on DisableKeepAlives to the transport settings
|
||||
// to allow for disabling HTTP keep-alive connections
|
||||
transport.DisableKeepAlives = upstream.DisableKeepAlives
|
||||
|
||||
// Apply the customized transport to our proxy before returning it
|
||||
proxy.Transport = transport
|
||||
|
||||
|
||||
@@ -372,12 +372,13 @@ var _ = Describe("HTTP Upstream Suite", func() {
|
||||
})
|
||||
|
||||
type newUpstreamTableInput struct {
|
||||
proxyWebSockets bool
|
||||
flushInterval options.Duration
|
||||
skipVerify bool
|
||||
sigData *options.SignatureData
|
||||
errorHandler func(http.ResponseWriter, *http.Request, error)
|
||||
timeout options.Duration
|
||||
proxyWebSockets bool
|
||||
flushInterval options.Duration
|
||||
skipVerify bool
|
||||
sigData *options.SignatureData
|
||||
errorHandler func(http.ResponseWriter, *http.Request, error)
|
||||
timeout options.Duration
|
||||
disableKeepAlives bool
|
||||
}
|
||||
|
||||
DescribeTable("newHTTPUpstreamProxy",
|
||||
@@ -391,6 +392,7 @@ var _ = Describe("HTTP Upstream Suite", func() {
|
||||
InsecureSkipTLSVerify: in.skipVerify,
|
||||
ProxyWebSockets: &in.proxyWebSockets,
|
||||
Timeout: &in.timeout,
|
||||
DisableKeepAlives: in.disableKeepAlives,
|
||||
}
|
||||
|
||||
handler := newHTTPUpstreamProxy(upstream, u, in.sigData, in.errorHandler)
|
||||
@@ -412,6 +414,9 @@ var _ = Describe("HTTP Upstream Suite", func() {
|
||||
if in.skipVerify {
|
||||
Expect(transport.TLSClientConfig.InsecureSkipVerify).To(Equal(true))
|
||||
}
|
||||
if in.disableKeepAlives {
|
||||
Expect(transport.DisableKeepAlives).To(Equal(true))
|
||||
}
|
||||
},
|
||||
Entry("with proxy websockets", &newUpstreamTableInput{
|
||||
proxyWebSockets: true,
|
||||
@@ -463,6 +468,15 @@ var _ = Describe("HTTP Upstream Suite", func() {
|
||||
errorHandler: nil,
|
||||
timeout: options.Duration(5 * time.Second),
|
||||
}),
|
||||
Entry("with a DisableKeepAlives", &newUpstreamTableInput{
|
||||
proxyWebSockets: false,
|
||||
flushInterval: defaultFlushInterval,
|
||||
skipVerify: false,
|
||||
sigData: nil,
|
||||
errorHandler: nil,
|
||||
timeout: defaultTimeout,
|
||||
disableKeepAlives: true,
|
||||
}),
|
||||
)
|
||||
|
||||
Context("with a websocket proxy", func() {
|
||||
|
||||
Reference in New Issue
Block a user