<p>I was configuring the gce ingress on my kubernetes cluster and I specified a Django application as default backend. The app enforces HTTPS so if you try to do a simple HTTP request Django will return a 301. Obviously HTTP health check will not pass. I was following this <a href="https://github.com/kubernetes/ingress-gce/blob/master/examples/backside-https/app.yaml" rel="nofollow noreferrer">example</a> to enable the HTTPS health check. Once the health check was spawned I manually edited the path in compute engine but from the Django app logs it seems that it hasn't received any requests, so it results UNHEALTHY and I can't get the ingress to work.</p>

<p>How can I make the health check to work in this case?</p>

<p>Configuration:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  annotations:
    kubernetes.io/tls-acme: "true"
    kubernetes.io/ingress.global-static-ip-name: web-static-ip
spec:
  tls:
  - hosts:
    - foo.domain.it
    secretName: production-tls
  backend:
    serviceName: app
    servicePort: app-https

apiVersion: v1
kind: Service
metadata:
  name: app
  annotations:
    service.alpha.kubernetes.io/app-protocols: '{"app-https":"HTTPS"}'
  labels:
    component: app
    role: web
spec:
  type: NodePort
  ports:
  - port: 12345
    targetPort: 8000
    protocol: TCP
    name: app-https
  selector:
    component: app
    role: web
  type: LoadBalancer

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: app
  labels:
    component: app
    role: web
spec:
  replicas: 1
  template:
    metadata:
      labels:
        component: app
        role: web
    spec:
      containers:
        - name: app
          image: [my-image]
          imagePullPolicy: Always
          ports:
          - containerPort: 8000
          envFrom:
          - configMapRef:
              name: app-config
</code></pre>

<p>As a workaround, I disabled the <code>DJANGO_SECURE_SSL_REDIRECT</code> and forced the ingress to accept only HTTPS request in case of GCE ingress.
<code>kubernetes.io/ingress.allow-http: "false"</code></p>

<p>If you are using NGINX as ingress just set
<code>nginx.ingress.kubernetes.io/ssl-redirect: "True"</code></p>
