I am using kong ingress controller and kong gateway in kubernetes. How do I redirect https://domain1.com to https://domain2.com?
Here’s my attempt:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: domain1-com
annotations:
konghq.com/protocols: https
konghq.com/methods: "GET"
konghq.com/plugins: "domain1-com-redirect"
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
ingressClassName: kong
rules:
- host: domain1.com
http:
paths:
- path: /~/*
pathType: ImplementationSpecific
backend:
service:
name: lend-tech
port:
number: 443
tls:
- hosts:
- domain1.com
secretName: domain1-com-tls-certificate
kind: Service
apiVersion: v1
metadata:
name: domain2-tech
annotations:
konghq.com/protocol: https
konghq.com/host-header: domain2.tech
spec:
ports:
- name: https
protocol: TCP
port: 443
targetPort: 443
type: ExternalName
externalName: domain2.tech
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: domain1-com-redirect
config:
header_filter:
- kong.response.exit(301, 'Page moved - redirecting...', {['Location'] = 'https://domain2.tech'})
plugin: post-function