Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enforce HTTP to HTTPS redirection in Google Cloud's bucket

I deployed my Vue.js SPA with Google Cloud's Storage Bucket.

Google's balancer does not let me configure the redirection from HTTPS to HTTP. The .htaccess file is not acknowledged either (at least, as per other StackOverflow questions I stumbled upon).

How do I enforce the redirection from HTTP to HTTPS in the context of GCP's storage bucket?

I was thinking about modifying the Router itself in my application, but

  • it's a dirty hack;
  • leads to unnecessary extra call;
  • technically does not seem to be solvable -- routes are expressed as relative to domain root anyway (i.e. i don't have the schema+domain information to use for programmatic redirect, as in /, /resume, /manifesto)...
like image 727
Igor Soloydenko Avatar asked Mar 09 '23 05:03

Igor Soloydenko


1 Answers

If you are using static website serving there is no way to use HTTPS, let alone redirecting HTTP.

If you are directly serving from storage.googleapis.com/bucket or bucket.storage.googleapis.com both HTTP and HTTPS will work but there is no way to stop plain HTTP from working.

You can use Google Cloud HTTPS Loadbalancing with a backend bucket. This will allow you to serve with HTTPS on a your own domain. You can then either have no plain HTTP at all or have HTTP traffic go to a different backend (e.g. a GCE instance that returns an HTTP 302 redirect or a different bucket with an index page that contains an HTML meta-redirect).

You could also use a third party CDN like Cloudflare in front of GCS to provide SSL features.

like image 161
David Avatar answered Apr 09 '23 22:04

David