You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何实现多域名关联单个GCS存储桶?官方文档规则存疑

How to Point Multiple Domains to a Single Google Cloud Storage Bucket

You’re right that GCS enforces bucket names to match the primary domain for static website hosting, but don’t worry—there are two reliable ways to get multiple domains serving content from the same bucket:

This approach lets all your domains display the same GCS content directly (no redirects) by routing traffic through a load balancer that acts as a middle layer.

  • Step 1: Set up your primary GCS bucket
    Create a bucket named after your main domain (e.g., example.com) and upload all your content here. Enable static website hosting if you’re serving a static site.

  • Step 2: Create a Cloud Load Balancer with a Backend Bucket

    1. Go to the Cloud Console’s Load Balancing page and create a new HTTP(S) load balancer.
    2. Choose the "From Internet to my VMs or serverless services" configuration.
    3. For the backend, select "Backend bucket" and link it to your primary GCS bucket.
    4. Assign a static external IP address to the load balancer (you’ll need this for DNS setup).
  • Step 3: Add SSL Certificates for All Domains
    Use Google Managed SSL Certificates to cover all your domains:

    1. In the load balancer’s HTTPS proxy setup, create a new managed certificate and list every domain you want to use (e.g., example.com, blog.example.com, docs.example.com).
    2. Google will automatically verify and issue the certificate for all listed domains.
  • Step 4: Update DNS Records
    For each domain you want to associate:

    • If using a domain with a DNS provider, create a CNAME record pointing to your load balancer’s static IP’s domain name (or an A record pointing directly to the static IP).

Now all your domains will route through the load balancer and serve content from your single GCS bucket.

Method 2: Domain Redirects (For Simple Use Cases)

If you don’t mind visitors being redirected to your primary domain, this is a lighter-weight option:

  • Step 1: Create empty buckets for extra domains
    For each additional domain (e.g., blog.example.com), create a GCS bucket with that exact domain name—you don’t need to upload any content here.

  • Step 2: Configure redirects
    In each empty bucket’s settings:

    1. Go to the "Website configuration" tab.
    2. Enable "Redirect all requests to another host name".
    3. Enter your primary domain (e.g., example.com) and choose a redirect type (301 for permanent, 302 for temporary).

Visitors to blog.example.com will automatically be sent to example.com, which serves content from your main bucket.


内容的提问来源于stack exchange,提问作者Rei OKawara

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:31:53