diff --git a/traefik/templates/_podtemplate.tpl b/traefik/templates/_podtemplate.tpl index d168f8d41..bd02d74c2 100644 --- a/traefik/templates/_podtemplate.tpl +++ b/traefik/templates/_podtemplate.tpl @@ -563,9 +563,12 @@ {{- range $entrypoint, $config := $.Values.ports }} {{- if $config }} {{- if $config.redirectTo }} - {{- $toPort := index $.Values.ports $config.redirectTo }} + {{- $toPort := index $.Values.ports $config.redirectTo.port }} - "--entrypoints.{{ $entrypoint }}.http.redirections.entryPoint.to=:{{ $toPort.exposedPort }}" - "--entrypoints.{{ $entrypoint }}.http.redirections.entryPoint.scheme=https" + {{- if $config.redirectTo.priority }} + - "--entrypoints.{{ $entrypoint }}.http.redirections.entryPoint.priority={{ $config.redirectTo.priority }}" + {{- end }} {{- end }} {{- if $config.middlewares }} - "--entrypoints.{{ $entrypoint }}.http.middlewares={{ join "," $config.middlewares }}" diff --git a/traefik/tests/deployment-config_test.yaml b/traefik/tests/deployment-config_test.yaml index 740e0537b..a738c0a3b 100644 --- a/traefik/tests/deployment-config_test.yaml +++ b/traefik/tests/deployment-config_test.yaml @@ -163,4 +163,32 @@ tests: content: "--entrypoints.websecure.http3" - contains: path: spec.template.spec.containers[0].args - content: "--entrypoints.websecure.http3.advertisedPort=443" \ No newline at end of file + content: "--entrypoints.websecure.http3.advertisedPort=443" + - it: should have http redirections enabled, when enabled with redirectTo + set: + ports: + web: + redirectTo: + port: websecure + websecure: + exposedPort: 443 + asserts: + - contains: + path: spec.template.spec.containers[0].args + content: "--entrypoints.web.http.redirections.entryPoint.to=:443" + - contains: + path: spec.template.spec.containers[0].args + content: "--entrypoints.web.http.redirections.entryPoint.scheme=https" + - it: should have http redirections enabled, when enabled with redirectTo and priority + set: + ports: + web: + redirectTo: + port: websecure + priority: 10 + websecure: + exposedPort: 443 + asserts: + - contains: + path: spec.template.spec.containers[0].args + content: "--entrypoints.web.http.redirections.entryPoint.priority=10" \ No newline at end of file diff --git a/traefik/values.yaml b/traefik/values.yaml index 320e15b94..991d3b396 100644 --- a/traefik/values.yaml +++ b/traefik/values.yaml @@ -616,7 +616,10 @@ ports: # Port Redirections # Added in 2.2, you can make permanent redirects via entrypoints. # https://docs.traefik.io/routing/entrypoints/#redirection - # redirectTo: websecure + # redirectTo: + # port: websecure + # (Optional) + # priority: 10 # # Trust forwarded headers information (X-Forwarded-*). # forwardedHeaders: