Open Ask AI (⌘/Ctrl+I)

Redirects

To use redirects in DX Cloud, create them directly via the Cockpit if you are dealing with larger numbers of redirects. If you only have a few redirects (e.g. fewer than 10), you can manage them directly in a redirects ingress.

Create a redirect ingress

In Rancher

  1. Go to Rancher.
  2. In the cluster where you want the redirects, 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>

The URL where you want to redirect visitors. See here for more details.

The 308 permanent redirect http status code. See here for more details.

The source domain. This must be registered in the ingress.

From the command line

  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>

The URL where you want to redirect visitors. See here for more details.

The 308 permanent redirect http status code. See here for more details.

The source domain. This must be registered in the ingress.

  1. Deploy it with the following command:
kubectl -n NAMESPACE apply -f REDIRECT_INGRESS_FILE_NAME <1>

Example REDIRECT_INGRESS_FILE_NAME could be something like www.hostname.to.redirect.yaml.

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

The relative path where you want to redirect visitors.