Redirect all HTTP traffic to HTTPS when using the HTTP(S) Load Balancer on Google Compute Engine

Solution 1:

We have a similar setup using the HTTP / HTTPS load balancer and we managed to force HTTPS. Its not possible directly from the load balancer but you can set it up from your backend service. The Google Cloud load balancer will set the X-Forwarded-Proto http header with either the value http or https. You check this header in your backend service (in our case Varnish but this could also be done in Nginx) and if the value is http then you send back a 301.

Solution 2:

Currently, you can do it directly from HTTP(S) Load Balancing. Google Cloud released Rewrites and Redirects support (since April 2020).

See this article to learn how to setup:

https://cloud.google.com/load-balancing/docs/https/setting-up-traffic-management#console More details about this feature:

https://cloud.google.com/load-balancing/docs/features#routing_and_traffic_management