diff --git a/common-services/traefik/middlewares.yaml b/common-services/traefik/middlewares.yaml index e60da78..f422754 100644 --- a/common-services/traefik/middlewares.yaml +++ b/common-services/traefik/middlewares.yaml @@ -6,4 +6,36 @@ metadata: spec: ipWhiteList: sourceRange: - - 0.0.0.0/0 \ No newline at end of file + - 0.0.0.0/0 + +--- +# Redirect no-www URLs to their www equivalent +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: redirect-no-www-to-www +spec: + # Redirect a request from an url to another with regex matching and replacement + redirectRegex: + # Apply a permanent redirection (HTTP 301) + permanent: true + # The regular expression to match and capture elements from the request URL + regex: ^https?://(?:www\\.)?(.+) + # How to modify the URL to have the new target URL + replacement: https://www.${1} + +--- +# Redirect www URLs to their no-www equivalent +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: redirect-www-to-no-www +spec: + # Redirect a request from an url to another with regex matching and replacement + redirectRegex: + # Apply a permanent redirection (HTTP 301) + permanent: true + # The regular expression to match and capture elements from the request URL + regex: ^https?://www\\.(.+) + # How to modify the URL to have the new target URL + replacement: https://${1} \ No newline at end of file