7

i have activated a HTTPS loadbalancer on GCP, with SSL certificate. On fronted i have specified HTTPS/443 as listening protocol and HTTP to comunication with backend.

https it working nicely, but loadbalancer also accept http/80 connection resulting in a 404 page.

Is there any way to forward http to https directly from loadbalancer?

thank you

x86fantini
  • 302
  • 1
  • 3
  • 9

2 Answers2

4

Just create a second forwarding rule on the load balancer for port 80. Both will use the same backend service.

If you want to forward users from http to https then you can't do this from the load balancer. You will have to set this up in your backend service. You can find more details here: https://stackoverflow.com/questions/38201969/redirecting-http-to-https-in-google-cloud/38202272

3

Create a static global IP address first

An Ephemeral IP or a static IP belong to any region doesn't work for the GCP HTTP(S) load balancer because it handles an IP to only a port. You can set a static global IP to both ports 80/443 on your load balancer.

I'm guessing a possible reason is that GCP load balancer doesn't belong to any region.

enter image description here

kujiy
  • 466
  • 6
  • 11
  • I don't recommend the way that @kujiy suggested, that will end up a warning of IP address conflict since 1 static IP only servers for 1 port A better way is by solving this problem is you can assign An Ephemeral IP to your port 80(http), and in your application layer, make your server listen to all traffic and redirect http request to https. – gijonc Sep 12 '18 at 04:17