Skip to content

Commit

Permalink
feat: 💥 support http redirections and http challenges with cert-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
renebarbosafl authored Oct 19, 2023
1 parent 6b2268f commit 8cf14c8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
5 changes: 4 additions & 1 deletion traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
30 changes: 29 additions & 1 deletion traefik/tests/deployment-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,32 @@ tests:
content: "--entrypoints.websecure.http3"
- contains:
path: spec.template.spec.containers[0].args
content: "--entrypoints.websecure.http3.advertisedPort=443"
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"
5 changes: 4 additions & 1 deletion traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8cf14c8

Please sign in to comment.