Kong Ingress Annotations (Redirect)

Greetings,

I was wondering if kong ingress had an anotation similar to NGINX’s nginx.ingress.kubernetes.io/permanent-redirect

I won’t go too much in detail what i’m trying to do, but this would quickly solve my issue.

Thanks,
Sartigan

1 Like

You can do this using KongIngress resource.
Create a KongIngress resource with route.https_redirect_status_code set to 301 and then annotate your Ingress resource with configuration.konghq.com: <name of KongIngress resource..

Hi @hbagdi,

I have followed that document. But I am getting redirect loop on https
What am I missing?

sh-4.2$ curl -I http://2048.test.com
HTTP/1.1 302 Moved Temporarily
Date: Tue, 11 Feb 2020 16:07:26 GMT
Content-Type: text/html
Content-Length: 110
Connection: keep-alive
Location: https://2048.test.com
X-Kong-Response-Latency: 0
Server: kong/1.4.3

sh-4.2$ curl -I https://2048.test.com
HTTP/1.1 302 Moved Temporarily
Date: Tue, 11 Feb 2020 16:07:33 GMT
Content-Type: text/html
Content-Length: 110
Connection: keep-alive
Location: https://2048.test.com
X-Kong-Response-Latency: 1
Server: kong/1.4.3

Both HTTP and HTTPS are redirected causing loop.

See my configuration here: HTTP to HTTPS redirect with kong-ingress and TLS-offloading

Hi!

The first question was about a Kong alternative to NGINX’s annotation nginx.ingress.kubernetes.io/permanent-redirect.

This annotation allows to return a permanent redirect (Return Code 301) instead of sending data to the upstream. For example nginx.ingress.kubernetes.io/permanent-redirect: https://www.google.com would redirect everything to Google.
https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/nginx-configuration/annotations.md#permanent-redirect

For my understanding, answer provided is for redirecting on same host with HTTPS.

Is there a way in Kong Ingress to redirect to another URL?

1 Like

joining @seboudry - is there such option or do we need to write custom plugins?