Support http to https redirection based on $http_x_forwarded_proto · Issue #115 · nginx/kubernetes-ingress (original) (raw)

I am using this ingress controller behind an ELB on AWS and have configured the ELB to do all of the SSL termination. However, since I also want to accept standard HTTP requests, I've opened port 80 on the ELB as well.

This works great except for one detail: I'd like all connections to be over HTTPS and thus need to be able to define (for each ingress resource) a 301 redirect to HTTPS if the request is sent over HTTP.

Looking through the code, I can see that this is the default behavior if SSL termination is configured on the ingress controller itself, but given that my ELB is doing the SSL termination, the connection from the ELB to the ingress controller is always HTTP-only.

Would it be an easy addition to add an annotation/ConfigMap key that would allow this behavior? Something like: nginx.org/redirect-to-https that would enable a rule in the conf file such as:

if ($http_x_forwarded_proto = 'http') {
    return 301 https://$host$request_uri;
}

...or would this conflict with other configuration options? If this type of behavior is already possible using another combination of annotations or ConfigMap settings, please let me know.