Learn how to set up a subdomain with Google Cloud and CloudFlare in a simple step-by-step guide with DNS, GCS, and Apache configuration. Our Live Support team is always here to help you
Creating a Subdomain with Google Cloud + CloudFlare Made Easy
Most website owners eventually need subdomains. For instance, blog.example.com might host your articles, support.example.com could handle customer requests, and store.example.com would serve as your shop. Setting one up isn’t complicated when you combine Google Cloud and CloudFlare. In this article, we’ll go directly into how Creating a subdomain with Google Cloud + CloudFlare works without any unnecessary detours.

Why subdomains matter
A subdomain allows you to split different parts of your site without affecting the main domain. Even if you only want a simple www subdomain, it’s still useful because many users type it before a domain name. That’s why adding proper DNS records matters for stability and accessibility.
Setting up the Google Cloud Storage bucket
To begin, you first need a separate Google Cloud Storage (GCS) bucket for the subdomain.
1. Open your GCS dashboard.
2. Create a new bucket with the exact subdomain name, for example: foo.bar.com.
3. Verify ownership of the domain. If you already verified bar.com, you don’t need to repeat it.
4. Upload your files into the bucket.
5. Change the bucket settings to public.
6. Configure the bucket website options.
Once that’s done, it’s time to move over to CloudFlare.
Adding the DNS record in CloudFlare
Now open your CloudFlare dashboard:
- Go to the DNS settings for bar.com.
- Add a new record with the following details:
Type: CNAME
Name: foo (your subdomain)
Value: c.storage.googleapis.com
TTL: Automatic TTL
After saving, wait a few minutes. Then test your subdomain in the browser.
Keep in mind that you cannot create a DNS record for foo.com/bar. Instead, in CloudFlare, you can set up a page rule to redirect foo.com/bar to bar.foo.com. For this to work, make sure your domain is routed through CloudFlare with the orange cloud active.
Handling Bitnami LAMP deployments on Google Cloud
If you are using Bitnami’s LAMP stack on Google Cloud, you will need to manually create a virtual host. This is the exact configuration you should add inside /opt/bitnami/apache2/conf/bitnami/bitnami.conf:
<VirtualHost *:80>
ServerName foo.bar.com
ServerAdmin foo@bar.com
DocumentRoot "/opt/bitnami/apache2/htdocs/foo"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/opt/bitnami/apache2/htdocs/foo">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
LogLevel warn
</VirtualHost>
After saving, restart Apache with:
sudo /opt/bitnami/ctlscript.sh restart apache
Finally, in CloudFlare, add an A record in your DNS:
- Name: foo
- Value: your Google Cloud VM’s IP address
You may leave the status as bypass (grey cloud) or active (orange cloud).
[If needed, Our team is available 24/7 for additional assistance.]
Conclusion
By following these steps, you’ve set up and linked your subdomain using Google Cloud and CloudFlare. This approach not only simplifies management but also enhances performance and security. With the flexibility of CloudFlare and the power of Google Cloud, creating subdomains becomes reliable and efficient.
Using this method, you can confidently expand your site with dedicated sections like blog, support, or store. Ultimately, Creating a subdomain with Google Cloud + CloudFlare gives you the control you need to grow your online presence.
