0
votes

I have created a load balancer on GCP. It supports both http and https. I want to change it so that it supports only https. I considered referring to this document https://cloud.google.com/load-balancing/docs/https/setting-up-http-https-redirect but it seems to create two separate load balancers.

As I already have a load balancer which is currently serving both http and https traffic, I'll prefer that I change the existing one. How could I do it?

Load balancer set up looks like this

[![enter image description here][1]][1]

The load balancer connects with two backend services

[![enter image description here][2]][2]

I suppose I should add a host and path rules but I can't figure out what should be the rule to redirect all http traffic with 301.

[![enter image description here][3]][3]

Would host be the domain name of my web application (eg. www.mydomain.com)?

The path rule takes url path but not url scheme (http). How do I specify that do redirect only for http traffic?

[![enter image description here][4]][4]

1
If your load balancer is for a public website, do not disable HTTP. The default today is HTTP when a user enters a url without a protocol. Without an HTTP listener your website will appear to be down. Implement the HTTP -> HTTPS redirect in your backend and configure both HTTP and HTTPS frontend listeners. - John Hanley
Agree John - the intent is to keep http ON but redirect http traffic to https using 301. But I can't figure out how to configure that in my current load balancer. I tried creating another load balancer for http as per the link in my question. That should redirect the requests to https load balancer but so far it is not working. Maybe it takes some time for the configurations to take effect. - Manu Chadha
Reread my comment. Configure the redirect in your backend. - John Hanley
got it working. I thijnk it just took time to configure. Removed the http frontend rule from my existing https load balancer and created a new one as per the link to route http traffic to https - Manu Chadha
@manu, we see your project ID in screenshots, please edit for security purposes. - dany L

1 Answers

0
votes

Seems like you are using GKE, so this setup might be different.

On your Ingress you must use the following annotation as per doc

kubernetes.io/ingress.allow-http: "false"

This will tell GCP to only use HTTPS when creating your Load Balancer, please note that this (as per today) will only work when creating your Ingress deployment, if you edit this onto an existing Ingress it will be accepted but not be deployed.

After that, you can use the guide you were using to deploy a secondary HTTP Load Balancer (with the same external IP address) in order to route your requests for HTTPS.