Redirect from application receiving wrong port from ingress

2020-02-14 nginx kubernetes-ingress nginx-ingress

We have an application which will redirect https://hostname.com/test to https://hostname.com/redirected. This works fine without the ingress. When the ingress is added infront, it will instead change the redirect to https://hostname:80/redirected, which obviously is not desireable. SSL is not handled by the ingress itself- traffic comes in to the ingress on port 80 (http).

$ curl -vI https://hostname.com/test1
...
HTTP/1.1 301 Moved Permanently
Location: https://hostname.com:80/redirected
...

What I want, is to just stop the ingress from changing anything in the location of redirects. Whatever response is sent from the backend applications, should just be propagated.

The only possible fix we've identified is to use the following annotations, which we would prefer to avoid since it's just an ugly workaround:

nginx.ingress.kubernetes.io/proxy-redirect-from: https://hostname.com:80
nginx.ingress.kubernetes.io/proxy-redirect-to: https://hostname.com

This was tested with nginx-ingress-controller 0.25.1 and 0.28.0

Big thanks for any help.

Answers

Related