DEV Community

Cover image for Kubernetes - Redirect HTTP to HTTPS with ELB and the nginx ingress controller

Kubernetes - Redirect HTTP to HTTPS with ELB and the nginx ingress controller

Tom Houlé on April 04, 2017

TL;DR Read the last paragraph for the most recent way of implementing HTTPS with an nginx ingress controller while letting ELB handle the certifica...
Collapse
 
tprakash17 profile image
DevOps Engineer

I got the point of putting following into ConfigMap

if ( $http_x_forwarded_proto = http ) {
rewrite .* https://$host$1 permanent;
}

Can you please paste configmap yaml just want to see the syntax how is above put in there.

Also, listeners are http and https at ELB? Not TCP right

Collapse
 
tprakash17 profile image
DevOps Engineer

Got this working.
Changed listeners on ELB to HTTP and HTTPS and following annotations on ingress seems to be working. SSL certificate still terminating on ELB.

Ingress annotation
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"

ELB listener setting.

Collapse
 
fwynyk profile image
fwynyk

Hey, nice article. But what about the ingress/controller yaml files?

Collapse
 
rastut profile image
Carlos Lopez

Ey we have a similar configuration but running over tcp. If we try to use as default backen http we always get a 504 error, the request die on the ELB. Any idea?

Collapse
 
tomhoule profile image
Tom Houlé

We haven't tried configuring ELB for TCP so I don't have interesting insight, but as a first step I'd try to tweak the LoadBalancer configuration. Sorry :/