Redirects using http instead of https when in k8s with tls hand off by ingress

12/9/2019

I have a service running in a docker container in Kubernetes. It has https/tls hand off by an ingress and then into the container via http. My issue is when the webApp that's running in the container returns a redirect or a request for the resource, it is returning http endpoints not https.

So for example:

Request: https://my.service

Returns redirect: http://my.service/login.html

Is there any way around this?

Thanks for your help.

-- Alizkat
docker
kubernetes
kubernetes-ingress
nginx-ingress

1 Answer

12/11/2019

I see your application is returning redirects to http and you are trying to rewrite these http to https in responses.

When using kubernetes nginx ingress controller adding these two annotations to your ingress object will solve your problem:

nginx.ingress.kubernetes.io/proxy-redirect-from: http
nginx.ingress.kubernetes.io/proxy-redirect-to: https

More details can be found in ingress controller annotation descriptions and in official nginx documentation

Let me know it it helped.

-- HelloWorld
Source: StackOverflow