fix: static upstreams failing validation due to passHostHeader and proxyWebSockets defaults being set incorrectly (#3302)

* fix: static upstream validation failure

Signed-off-by: Sourav Agrawal <souravagr01@gmail.com>

* fix: enforcement of defaults compatible with static upstreams

Signed-off-by: Jan Larwig <jan@larwig.com>

---------

Signed-off-by: Sourav Agrawal <souravagr01@gmail.com>
Signed-off-by: Jan Larwig <jan@larwig.com>
Co-authored-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
Sourav Agrawal
2026-01-17 15:15:19 +01:00
committed by GitHub
co-authored by Jan Larwig
parent 9c61c49ec2
commit 59f4e42a5a
6 changed files with 60 additions and 23 deletions
+3 -3
View File
@@ -70,13 +70,13 @@ func validateStaticUpstream(upstream options.Upstream) []string {
if ptr.Deref(upstream.InsecureSkipTLSVerify, options.DefaultUpsteamInsecureSkipTLSVerify) {
msgs = append(msgs, fmt.Sprintf("upstream %q has insecureSkipTLSVerify, but is a static upstream, this will have no effect.", upstream.ID))
}
if upstream.FlushInterval != nil && *upstream.FlushInterval != options.DefaultUpstreamFlushInterval {
if ptr.Deref(upstream.FlushInterval, options.DefaultUpstreamFlushInterval) != options.DefaultUpstreamFlushInterval {
msgs = append(msgs, fmt.Sprintf("upstream %q has flushInterval, but is a static upstream, this will have no effect.", upstream.ID))
}
if upstream.PassHostHeader != nil {
if ptr.Deref(upstream.PassHostHeader, options.DefaultStaticPassHostHeader) != options.DefaultStaticPassHostHeader {
msgs = append(msgs, fmt.Sprintf("upstream %q has passHostHeader, but is a static upstream, this will have no effect.", upstream.ID))
}
if upstream.ProxyWebSockets != nil {
if ptr.Deref(upstream.ProxyWebSockets, options.DefaultStaticProxyWebSockets) != options.DefaultStaticProxyWebSockets {
msgs = append(msgs, fmt.Sprintf("upstream %q has proxyWebSockets, but is a static upstream, this will have no effect.", upstream.ID))
}
+19 -1
View File
@@ -138,7 +138,7 @@ var _ = Describe("Upstreams", func() {
},
errStrings: []string{invalidURISchemeMsg},
}),
Entry("with a static upstream and invalid optons", &validateUpstreamTableInput{
Entry("with a static upstream and invalid options", &validateUpstreamTableInput{
upstreams: options.UpstreamConfig{
Upstreams: []options.Upstream{
{
@@ -161,6 +161,24 @@ var _ = Describe("Upstreams", func() {
staticWithProxyWebSocketsMsg,
},
}),
Entry("with a static upstream and sane default options", &validateUpstreamTableInput{
upstreams: options.UpstreamConfig{
Upstreams: []options.Upstream{
{
ID: "foo",
Path: "/foo",
URI: "ftp://foo",
Static: ptr.To(true),
PassHostHeader: ptr.To(false),
ProxyWebSockets: ptr.To(false),
InsecureSkipTLSVerify: ptr.To(false),
},
},
},
errStrings: []string{
staticWithURIMsg,
},
}),
Entry("with duplicate IDs", &validateUpstreamTableInput{
upstreams: options.UpstreamConfig{
Upstreams: []options.Upstream{