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
- Go to Rancher.
- 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
- 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.
- 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.