Redirects
To use redirects in Magnolia PaaS, you’ll create them directly via the Cockpit if you are dealing with more than 10 redirects. If you have fewer than 10, you can manage them directly in a redirects ingress.
We recommend you use the Cockpit redirects option, especially if you have greater than 10 redirects.
|
Redirects prerequisites
You need to ensure the following prerequisites are met in order to use the redirects feature in Magnolia PaaS.
-
You should have already created a domain.
Create a redirect ingress
-
Go to Rancher.
-
In the cluster where you want the redirects, create a redirects ingress file.
Whether you are managing redirects (fewer than 20) directly in the ingress or via the Cockpit, you still must register the source domain (see 3 below) for any intended redirect URLs. apiVersion: extensions/v1beta1 kind: Ingress metadata: annotations: cert-manager.io/cluster-issuer: letsencrypt-prod kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/permanent-redirect: https://redirect.hostname.com/ (1) nginx.ingress.kubernetes.io/permanent-redirect-code: "308" (2) nginx.ingress.kubernetes.io/proxy-body-size: 512m name: www-hostname-to-redirect namespace: prod spec: rules: - host: www.hostname.com (3)1 The URL where you want to redirect visitors. See here for more details. 2 The 308permanent redirect http status code. See here for more details.3 The source domain. This must be registered in the ingress. Managing path redirects in ingress (
<10)
-
Create a redirects ingress file.
apiVersion: extensions/v1beta1 kind: Ingress metadata: annotations: cert-manager.io/cluster-issuer: letsencrypt-prod kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/permanent-redirect: https://redirect.hostname.com/ (1) nginx.ingress.kubernetes.io/permanent-redirect-code: "308" (2) nginx.ingress.kubernetes.io/proxy-body-size: 512m name: www-hostname-to-redirect namespace: prod spec: rules: - host: www.hostname.com (3)1 The URL where you want to redirect visitors. See here for more details. 2 The 308permanent redirect http status code. See here for more details.3 The source domain. This must be registered in the ingress. Managing path redirects in ingress (
<10) -
Deploy it with the following command:
kubectl -n NAMESPACE apply -f REDIRECT_INGRESS_FILE_NAME (1)1 Example REDIRECT_INGRESS_FILE_NAMEcould be something likewww.hostname.to.redirect.yaml.