Redirects
To use redirects in DX Cloud, create them in the Cockpit when you have more than a few.
A single whole-host redirect can be an MgnlIngress with nginxOptions.permanentRedirect.
Create a redirect ingress
Manifest
A whole-host redirect is an MgnlIngress with nginxOptions.permanentRedirect. Leave ingress.enabled off in values.yml.
apiVersion: magnolia.info/v1alpha1
kind: MgnlIngress
metadata:
name: www-hostname-to-redirect
namespace: prod
labels:
app.kubernetes.io/managed-by: pipeline
spec:
rules:
- host: www.hostname.com <1>
paths:
- path: /
pathType: Prefix
backendName: prod-magnolia-redirects-svc
backendPortName: http
nginxOptions:
permanentRedirect:
enabled: true
url: https://redirect.hostname.com/ <2>
redirectCode: 308 <3>
The source domain. This host must be on this MgnlIngress.
The URL visitors are sent to. See Map UI fields to manifest.
HTTP status code. Use 301, 302, 303, 307, or 308.
From the command line
-
Save the manifest above as a file in your pipeline repository.
-
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.
Path redirects are a list of source and target URLs. Create those in the Cockpit with Add redirects.