Deploying a Static Website on Google Cloud Storage with GCP Load Balancer

Abstract: Configure Google Cloud Storage as a backend bucket to serve static websites through an external HTTP(S) load balancer with SSL termination.

Created: 2026-09-25 by
You can deploy a static website on Google Cloud Storage and serve it through an external HTTP(S) load balancer by configuring GCS as a backend bucket. This setup requires creating a storage bucket with uniform or fine-grained access, setting up a backend service that references the bucket, and attaching a health check to ensure traffic is routed only to healthy resources. The load balancer acts as a reverse proxy, handling SSL termination and distributing requests to your static content without exposing the raw storage endpoint to the public internet.

Prerequisites and Bucket Configuration

Before configuring the load balancer, you must prepare the Google Cloud Storage (GCS) bucket to serve static files correctly. The most critical step is enabling website hosting on the bucket. Without this, the load balancer cannot determine which file to serve when a user requests a directory path, such as /.

  1. Navigate to the Cloud Storage browser in the Google Cloud Console.
  2. Select your target bucket and click the Properties tab.
  3. Scroll to the Website Hosting section and click Edit.
  4. Enter the name of your index page (e.g., index.html) in the Main Page Name field.
  5. If you have custom error pages, specify them in the 404 Error File field.
  6. Click Save.

Next, ensure the bucket has appropriate permissions. If you are using Uniform IAM, the storage.objects.get permission must be granted to the allUsers or allAuthenticatedUsers identity. Alternatively, if you use Fine-Grained Access Control, you can attach a predefined role like Storage Object Viewer to the allUsers principal. This allows the load balancer’s health checks and incoming traffic to read the objects from the bucket.

Creating the Backend Service

The core of this architecture is the Backend Service, which defines where traffic goes. In Google Cloud Platform, an HTTP(S) Load Balancer does not support GCS directly as a "bucket backend" in the same way some CDNs do. Instead, you create a backend service that uses the GCS bucket as its origin. However, standard HTTP(S) LB backends typically expect Compute Engine instances or Cloud Run services. To use GCS effectively with an external HTTP(S) LB, you often need a workaround involving a Cloud Functions or Cloud Run service that proxies requests, OR you utilize the fact that GCS buckets can be accessed via their native URL structure if configured as a CDN-backed bucket.

Note: A common architectural pattern for serving static sites via GCP Load Balancer involves using a Cloud Run service or Cloud Function as the backend that fetches content from GCS, because direct GCS integration into the standard HTTP(S) LB backend pool is not natively supported for dynamic routing in the same way VMs are. However, for pure static hosting, many users opt for Google Cloud CDN directly attached to a GCS bucket, which bypasses the need for a complex Load Balancer setup. If strict Load Balancer features like advanced routing rules are required, a proxy service is necessary.

For the purpose of this guide, we will assume the standard approach of using a Backend Bucket. While older documentation might suggest otherwise, modern GCP allows you to create a Backend Bucket resource. Here is how:

  1. Go to Load Balancing > Create Load Balancer.
  2. Select HTTP(S) Load Balancing and click Continue.
  3. In the Backend configuration section, click Create Backend Bucket.
  4. Name your backend bucket and select the GCS bucket you created earlier.
  5. Ensure CDN is enabled if you want caching benefits, though this is optional for basic functionality.
  6. Click Create.

This creates a specialized backend type optimized for static assets. It simplifies the configuration by removing the need for health checks against individual servers, as the bucket itself is the source of truth.

Configuring Health Checks

When using a standard Backend Service with Compute Engine instances, health checks are mandatory. However, when you use a Backend Bucket (as described above), the load balancer treats the entire bucket as a single logical unit. You do not configure traditional TCP/HTTP health checks against specific IP addresses. Instead, the system validates the bucket's existence and accessibility during the initial handshake.

If you were forced to use a Backend Service with VMs acting as proxies to GCS, you would need to define a Health Check resource. Go to VPC Network > Health checks and create an HTTP health check targeting the root path /. Set the request path to /, the port to 80, and the healthy threshold to 2. Attach this health check to your backend service. This ensures that traffic is only sent to VMs that can successfully retrieve the index.html file from the GCS bucket.

Setting Up Frontend and Routing

The frontend configuration handles incoming traffic from users. Create a Frontend Configuration with a new IP address (static IP recommended for production). Select HTTPS if you plan to use SSL certificates. For HTTPS, you must create an SSL certificate in the Certificate Manager or upload one manually. Attach this certificate to the frontend port 443.

In the Host and Path Rules section, set the host rule to match your domain (e.g., *.example.com) and leave the path as /* to route all traffic to the backend bucket. Click Create to finalize the load balancer. Propagation may take several minutes.

It is important to note that unlike AWS ALBs, GCP Load Balancers do not have a native "Redirect HTTP to HTTPS" toggle in the UI. To enforce HTTPS, you must create a separate HTTP load balancer on port 80 that redirects to the HTTPS listener, or handle redirection within your application code if you are using a proxy service.

Verification and Troubleshooting

Once deployed, verify the setup by navigating to your load balancer’s IP address or domain. If you see your website, the configuration is successful. If you encounter a 502 Bad Gateway error, check the backend bucket configuration to ensure the correct GCS bucket is selected. If you see a 403 Forbidden error, verify the IAM permissions on the GCS bucket allow public read access.

For more details on managing cloud infrastructure across providers, you might find our guide on Improving Cloud Infrastructure: AWS, GCP, Azure VMware Experiences helpful for broader context.

Frequently Asked Questions

Can I use a GCS bucket directly without a load balancer?

Yes, you can enable Google Cloud CDN directly on a GCS bucket. This is often simpler and cheaper than setting up a full HTTP(S) Load Balancer. It provides global caching and DDoS protection without managing backend instances or complex routing rules.

Why did my deployment fail with a 403 Forbidden error?

This usually indicates that the GCS bucket does not have public read permissions. Ensure that the allUsers identity has the Storage Object Viewer role assigned, or that uniform bucket-level access is configured to allow anonymous reads.

Is a health check required for Backend Buckets?

No, traditional health checks are not required for Backend Buckets because the bucket is treated as a single logical entity. The load balancer validates the bucket's availability at the time of connection rather than polling individual servers.

How do I force HTTP to redirect to HTTPS?

GCP Load Balancers do not have a built-in toggle for this. You must create a second HTTP load balancer on port 80 with a URL map that returns a 301 redirect to the HTTPS version of your domain, or implement the redirect logic in your static site's HTML/JavaScript.

What happens if the GCS bucket is deleted?

If the backend bucket reference points to a deleted GCS bucket, the load balancer will return 502 Bad Gateway errors for all incoming requests. Always ensure the underlying storage resource exists before relying on the load balancer.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More