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

技术咨询:能否在Google Cloud无需自定义域名托管网站及HTML文件?

Absolutely! You can host static HTML files on Google Cloud Platform (GCP) without needing a custom domain—just like you’ve done with Cloudflare or AWS. Here are the two most reliable, straightforward methods to pull this off:

1. Google Cloud Storage (Best for Pure Static Content)

This is the simplest route if you’re only serving HTML, CSS, JS, and images:

  • First, create a Cloud Storage bucket. Heads up: The bucket name has to be globally unique, since it’ll be part of your default public URL.
  • Enable static website hosting for the bucket:
    1. Open your bucket in the GCP Console, go to the "Static website" tab.
    2. Set your main page suffix (usually index.html) and an error page (like 404.html) if you want one.
  • Upload all your HTML files and associated assets to the bucket.
  • Make your content public: You can either set the bucket’s permissions to allow public read access, or grant the allUsers group the Storage Object Viewer role.
  • Once everything’s set, you’ll get a default public URL. It’ll look something like https://storage.googleapis.com/[YOUR_BUCKET_NAME]/index.html or a regional endpoint like https://[YOUR_BUCKET_NAME].storage.googleapis.com/index.html.

2. Cloud Run (For More Flexibility)

If you might want to add dynamic features later, or prefer a cleaner default HTTPS URL, Cloud Run is a great choice:

  • Package your HTML files into a lightweight container. A super simple Dockerfile using Nginx works perfectly:
FROM nginx:alpine
COPY . /usr/share/nginx/html
  • Build the image with Google Cloud Build, then deploy it to Cloud Run.
  • When deploying, skip the custom domain setup—Cloud Run will automatically assign you a default HTTPS URL in the format https://[YOUR_SERVICE_NAME]-[RANDOM_HASH]-[YOUR_REGION].a.run.app.
  • Don’t forget to allow unauthenticated invocations if you want your site to be accessible to anyone.

Both methods give you a fully functional, public URL without any need to register or configure a custom domain. Stick with Cloud Storage if you’re just serving static files, and go with Cloud Run if you want room to grow your project later.

内容的提问来源于stack exchange,提问作者Ben Tailer

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 12:09:13