title: How to set HTTPS as default on GKE Ingress-gce
body: <p>I currently have a working Frontend and Backend nodeports with an Ingress service setup with GKE's Google-managed certificates.</p>
  <p>However, my issue is that by default <strong>when a user goes to samplesite.com, it uses http as default.</strong> This means that the user needs to specifically type in the browser <a href="https://samplesite.com" rel="nofollow noreferrer">https://samplesite.com</a> in order to get the https version of my website.</p>
  <p><strong>How do I properly disable http on GKE ingress, or how do I redirect all my traffic to https?</strong> I understand that this can be forcefully done in my backend code as well but I want to separate concerns and handle this in my Kubernetes setup.</p>
  <p>Here is my ingress.yaml file:</p>
  <pre><code>kind: Service
  apiVersion: v1
  metadata:
    name: frontend-node-service
    namespace: default
  spec:
    type: NodePort
    selector:
      app: frontend
    ports:
    - port: 5000
      targetPort: 80
      protocol: TCP
      name: http
  ---
  kind: Service
  apiVersion: v1
  metadata:
    name: backend-node-service
    namespace: default
  spec:
    type: NodePort
    selector:
      app: backend
    ports:
    - port: 8081
      targetPort: 9229
      protocol: TCP
      name: http
  ---
  apiVersion: networking.k8s.io/v1beta1
  kind: Ingress
  metadata:
    name: samplesite-ingress-frontend
    namespace: default
    annotations:
      kubernetes.io/ingress.global-static-ip-name: &quot;samplesite-static-ip&quot;
      kubernetes.io/ingress.allow-http: &quot;false&quot;
      networking.gke.io/managed-certificates: samplesite-ssl
  spec:
    backend:
      serviceName: frontend-node-service
      servicePort: 5000
  ---
  apiVersion: networking.k8s.io/v1beta1
  kind: Ingress
  metadata:
    name: samplesite-ingress-backend
    namespace: default
    annotations:
      kubernetes.io/ingress.global-static-ip-name: &quot;samplesite-backend-ip&quot;
      kubernetes.io/ingress.allow-http: &quot;false&quot;
      networking.gke.io/managed-certificates: samplesite-api-ssl
  spec:
    backend:
      serviceName: backend-node-service
      servicePort: 8081
  </code></pre>