title: kubernetes nginx ingress fails to redirect HTTP to HTTPS
body: <p>I have a web app hosted in the Google Cloud platform that sits behind a load balancer, which itself sits behind an ingress. The ingress is set up with an SSL certificate and accepts HTTPS connections as expected, with one problem: I cannot get it to redirect non-HTTPS connections to HTTPS. For example, if I connect to it with the URL <code>http://foo.com</code> or <code>foo.com</code>, it just goes to <code>foo.com</code>, instead of <code>https://foo.com</code> as I would expect. Connecting to <code>https://foo.com</code> explicitly produces the desired HTTPS connection. </p>
  
  <p>I have tried every annotation and config imaginable, but it stubbornly refuses, although it shouldn't even be necessary since docs imply that the redirect is automatic if TLS is specified. Am I fundamentally misunderstanding how ingress resources work? </p>
  
  <p><strong>Update</strong>: Is it necessary to <strong>manually install</strong> nginx ingress on GCP? Now that I think about it, I've been taking its availability on the platform for granted, but after coming across information on how to install nginx ingress on the Google Container Engine, I realized the answer may be a lot simpler than I thought. Will investigate further.</p>
  
  <p>Kubernetes version: <strong>1.8.5-gke.0</strong></p>
  
  <p>Ingress YAML file:</p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: https-ingress
    annotations:
      kubernetes.io/ingress.class: "nginx"
      ingress.kubernetes.io/ssl-redirect: "true" 
      ingress.kubernetes.io/secure-backends: "true"    
      ingress.kubernetes.io/force-ssl-redirect: "true"
  spec:
    tls:
      - hosts:
        - foo.com
        secretName: tls-secret
    rules:
      - host: foo.com
        http:
          paths:
            - path: /*
              backend:
                serviceName: foo-prod
                servicePort: 80
  </code></pre>
  
  <p><strong>kubectl describe ing https-ingress</strong> output</p>
  
  <pre><code>Name:             https-ingress
  Namespace:        default
  Address:
  Default backend:  default-http-backend:80 (10.56.0.3:8080)
  TLS:
    tls-secret terminates foo.com
  Rules:
    Host            Path  Backends
    ----            ----  --------
    foo.com
                    /*   foo-prod:80 (&lt;none&gt;)
  Annotations:
    force-ssl-redirect:  true
    secure-backends:     true
    ssl-redirect:        true
  Events:                &lt;none&gt;
  </code></pre>