Skip to content

Commit cb1565d

Browse files
authored
chore: Configure maxResponseBodySize for traefik (#2123)
* chore: Configure maxResponseBodySize for traefik Signed-off-by: Anatolii Bazko <abazko@redhat.com>
1 parent 66d80a3 commit cb1565d

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

pkg/deploy/gateway/traefik_config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ type TraefikConfigStripPrefix struct {
6262
}
6363

6464
type TraefikConfigForwardAuth struct {
65-
Address string `json:"address"`
66-
TrustForwardHeader bool `json:"trustForwardHeader"`
67-
TLS *TraefikConfigTLS `json:"tls,omitempty"`
65+
Address string `json:"address"`
66+
TrustForwardHeader bool `json:"trustForwardHeader"`
67+
TLS *TraefikConfigTLS `json:"tls,omitempty"`
68+
MaxResponseBodySize *int `json:"maxResponseBodySize,omitempty"`
6869
}
6970

7071
type TraefikConfigErrors struct {

pkg/deploy/gateway/traefik_config_util.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
package gateway
1414

15+
import "k8s.io/utils/pointer"
16+
1517
const (
1618
StripPrefixMiddlewareSuffix = "-strip-prefix"
1719
HeaderRewriteMiddlewareSuffix = "-header-rewrite"
@@ -88,8 +90,9 @@ func (cfg *TraefikConfig) AddOpenShiftTokenCheck(componentName string) {
8890
cfg.HTTP.Routers[componentName].Middlewares = append(cfg.HTTP.Routers[componentName].Middlewares, middlewareName)
8991
cfg.HTTP.Middlewares[middlewareName] = &TraefikConfigMiddleware{
9092
ForwardAuth: &TraefikConfigForwardAuth{
91-
Address: "https://kubernetes.default.svc/apis/user.openshift.io/v1/users/~",
92-
TrustForwardHeader: true,
93+
Address: "https://kubernetes.default.svc/apis/user.openshift.io/v1/users/~",
94+
TrustForwardHeader: true,
95+
MaxResponseBodySize: pointer.Int(16384), // 16KB
9396
TLS: &TraefikConfigTLS{
9497
InsecureSkipVerify: true,
9598
},
@@ -102,7 +105,8 @@ func (cfg *TraefikConfig) AddAuth(componentName string, authAddress string) {
102105
cfg.HTTP.Routers[componentName].Middlewares = append(cfg.HTTP.Routers[componentName].Middlewares, middlewareName)
103106
cfg.HTTP.Middlewares[middlewareName] = &TraefikConfigMiddleware{
104107
ForwardAuth: &TraefikConfigForwardAuth{
105-
Address: authAddress,
108+
Address: authAddress,
109+
MaxResponseBodySize: pointer.Int(16384), // 16KB
106110
},
107111
}
108112
}

0 commit comments

Comments
 (0)