Skip to content

Commit 5850630

Browse files
authored
fix(entryPoint): allow scheme to be unset on redirect
1 parent da94535 commit 5850630

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

traefik/templates/_podtemplate.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@
625625
{{- fail $errorMsg }}
626626
{{- end }}
627627
{{- $toPort := index $.Values.ports .to }}
628-
{{- if and (($toPort.tls).enabled) (ne .scheme "https") }}
628+
{{- if and (($toPort.tls).enabled) .scheme (ne .scheme "https") }}
629629
{{- $errorMsg := printf "ERROR: Cannot redirect %s to %s without setting scheme to https" $entrypoint .to }}
630630
{{- fail $errorMsg }}
631631
{{- end }}

traefik/tests/deployment-config_test.yaml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,18 +290,58 @@ tests:
290290
asserts:
291291
- failedTemplate:
292292
errorMessage: "ERROR: redirectTo syntax has been removed in v34 of this Chart. See Release notes or EXAMPLES.md for new syntax."
293-
- it: should fail when redirect on websecure without https scheme
293+
- it: should fail when redirect on websecure with tls enabled and non-https scheme
294294
set:
295295
ports:
296296
web:
297297
redirections:
298298
entryPoint:
299299
to: websecure
300+
scheme: http
300301
websecure:
301302
exposedPort: 443
303+
tls:
304+
enabled: true
302305
asserts:
303306
- failedTemplate:
304307
errorMessage: "ERROR: Cannot redirect web to websecure without setting scheme to https"
308+
- it: should redirect on websecure with tls enabled and https scheme
309+
set:
310+
ports:
311+
web:
312+
redirections:
313+
entryPoint:
314+
to: websecure
315+
scheme: https
316+
websecure:
317+
exposedPort: 443
318+
tls:
319+
enabled: true
320+
asserts:
321+
- contains:
322+
path: spec.template.spec.containers[0].args
323+
content: "--entryPoints.web.http.redirections.entryPoint.scheme=https"
324+
- contains:
325+
path: spec.template.spec.containers[0].args
326+
content: "--entryPoints.web.http.redirections.entryPoint.to=:443"
327+
- it: should not fail when redirect on websecure with unset scheme
328+
set:
329+
ports:
330+
web:
331+
redirections:
332+
entryPoint:
333+
to: websecure
334+
websecure:
335+
exposedPort: 443
336+
tls:
337+
enabled: true
338+
asserts:
339+
- notContains:
340+
path: spec.template.spec.containers[0].args
341+
content: "--entryPoints.web.http.redirections.entryPoint.scheme="
342+
- contains:
343+
path: spec.template.spec.containers[0].args
344+
content: "--entryPoints.web.http.redirections.entryPoint.to=:443"
305345
- it: should fail when redirect on non-existent entrypoint
306346
set:
307347
ports:

0 commit comments

Comments
 (0)