Using:
Kong Ingress 2.0.5
EKS cluster
Is there a way to simple, 301 redirections just with an Ingress/KongIngress/KongPlugin configuration?
My use-case is:
user enters www.foo.com
, has to be redirected to app.bar.com
with a 301 Redirect.
I’ve already tried request-transformer and request-termination like this:
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: dev-redirect-transformer
config:
add:
headers:
- "Location: https://app.bar.com"
- "demo: injected-by-kong"
plugin: request-transformer
enabled: true
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: dev-redirect-termination
config:
status_code: 301
message: "test"
plugin: request-termination
enabled: true
And serverless like this:
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: dev-redirect-post
config:
header_filter: kong.response.exit(301, 'page moved - redirecting...', {['Location'] = 'https://app.bar.com/' .. kong.request.get_path_with_query():gsub("%/test1/", "/test2/")})
plugin: post-function
with this Ingress configuration:
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: dev-other-ingress-test
namespace: redirect-test
annotations:
konghq.com/plugins: "dev-redirect-post"
or
konghq.com/plugins: "dev-redirect-transformer"
konghq.com/plugins: "dev-redirect-termination"
spec:
rules:
- host: www.foo.com
tls:
- hosts:
- www.foo.com
secretName: foo-ssl
To no avail.
Am I doing something/wrong, is this even possible just with Kong?
Any help is appreciated, thanks.