Routing multiple domains to the same GCP bucket, but with different html entrypoints
05/09/2025 13:33
I host my AI chat and workflow website on two different domains.
The reason why I have multiple domains for
the same application, is that some domains have country-specific
features.
Under the hood, they share the same codebase, but conditionally renders some features depending on which domain the user comes from.
The first domain is https://flune.ai/, and it is in English language by default.
The second domain is https://letai.dk/, and it is in Danish language by default.
The setup
For hosting the site, I simply use a Google Cloud Bucket.
I point both domains to a Google Cloud Load Balancer, which then returns files from the bucket.
My GitHub workflows file sends the files to the bucket automatically on merge to main.
Inconvenience
Since the build results in a single .html file, if I send the site to someone on let's say Discord, it will show the same metadata on BOTH DOMAINS. Bad!
This will be the same on most social media platforms, as they simply parse the site's index.html file and extract relevant info from the header.
This made the international domain flune.ai appear as cryptic to non-danish speakers:
The fix
Luckily, you can fix this easily by using url mappings built into Google Cloud's load balancer.
Instead of having one index.html file, I split it into two files: letai.dk.html and flune.ai.html, each with correctly hardcoded metadata in the header, appropriate to the domain.
Then I got rid of index.html.
That of course made the website go 404, since there was no index.html.
So in the load balancer, I could set up a route for which file index.html should point to, for each domain, in the same bucket.
I created this .yaml file as configuration for my url map in the load balancer:
Then, I added it to my deployment pipeline:
And then, the site started routing correctly.
Running wget on each of the /index.html files on the different domains, they gave the correct reply!
I checked with Discord, and luckily it also shows up correctly there:
And that's it - the different domains now use the same bucket, but the /index.html file is routed differently depending on which domain that requests the site.
Url mapping in GCP is an awesome feature, and saves a lot of hazzle instead of building the site multiple times into different buckets.
I hope this helped you out! <3
0
0
Write a reply (0/3500)
Replies
No replies yet