Redirects

To use redirects in DX Cloud, 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.

Create a redirect ingress

  • In Rancher

  • From the command line

  1. Go to Rancher.

  2. 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: networking.k8s.io/v1
    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 308 permanent 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)

    If you want to fully manage the path redirects in the ingress (fewer than 10), you can define that as well under http:paths:path: as shown here. However, we recommend managing path redirects and registered source domain redirects in the Cockpit.

        http:
          paths:
          - backend:
              serviceName: prod-magnolia-helm-frontend-public-svc
              servicePort: http
            path: /redirect (1)
            pathType: Prefix
      tls:
      - hosts:
        - www.hostname.com
        - hostname.com
        secretName: www-hostname-com
    1 The relative path where you want to redirect visitors.
  1. Create a redirects ingress file.

    apiVersion: networking.k8s.io/v1
    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 308 permanent 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)

    If you want to fully manage the path redirects in the ingress (fewer than 10), you can define that as well under http:paths:path: as shown here. However, we recommend managing path redirects and registered source domain redirects in the Cockpit.

        http:
          paths:
          - backend:
              serviceName: prod-magnolia-helm-frontend-public-svc
              servicePort: http
            path: /redirect (1)
            pathType: Prefix
      tls:
      - hosts:
        - www.hostname.com
        - hostname.com
        secretName: www-hostname-com
    1 The relative path where you want to redirect visitors.
  2. Deploy it with the following command:

    kubectl -n NAMESPACE apply -f REDIRECT_INGRESS_FILE_NAME (1)
    1 Example REDIRECT_INGRESS_FILE_NAME could be something like www.hostname.to.redirect.yaml.
Feedback

PaaS

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the Magnolia PaaS docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules