静的WebサイトのホスティングとCDN配信
S3バケットから静的Webサイトを直接配信し、その前段にCloudFront CDNを配置してグローバル配信を高速化します。
「静的WebサイトのホスティングとCDN配信」はCoddyKit上の無料AWS for Backend Developers (EC2, S3, RDS, Lambda)レッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはAWS for Backend Developers (EC2, S3, RDS, Lambda)学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 AWS for Backend Developers (EC2, S3, RDS, Lambda)コースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
S3 as a Web Server
Beyond storing files, S3 can host a static website, HTML, CSS, JS, and images, with no servers to manage. It is cheap, scalable, and a perfect fit for single-page apps and documentation sites.
Enabling Static Hosting
You enable the static website hosting feature on the bucket and specify an index document (the home page) and an error document.
Index and Error Documents
The index document (often index.html) is served for the root and folder URLs. The error document handles 4xx responses, useful for SPA routing where you point errors back to index.html.
Uploading Your Site
Sync your build output into the bucket. The AWS CLI sync command uploads only changed files.
aws s3 sync ./dist s3://my-site-bucket --deleteContent Types Matter
S3 serves files with the Content-Type stored as metadata. If a CSS file is served as plain text, browsers ignore it. The CLI usually infers types, but verify for unusual extensions.
The Website Endpoint
Static hosting exposes a regional website endpoint URL. It is HTTP only and not ideal for production, which is exactly why we add a CDN next.
http://my-site-bucket.s3-website-us-east-1.amazonaws.comIntroducing CloudFront
CloudFront is AWS's content delivery network. It caches your site at edge locations worldwide, so users get fast responses from a nearby server and your bucket sees less load.
Origins and Distributions
A CloudFront distribution points at an origin (your S3 bucket). CloudFront fetches from the origin on a cache miss and serves the cached copy on subsequent requests.
HTTPS and Custom Domains
CloudFront gives you free HTTPS via AWS Certificate Manager and lets you attach a custom domain like www.example.com, things the raw S3 endpoint cannot do.
Locking Down the Bucket
For security, keep the bucket private and let only CloudFront read it using an Origin Access Control (OAC). Visitors reach content through the CDN, never the bucket directly.
Cache Invalidation
CloudFront caches aggressively. After deploying new content, invalidate the cache so users get the latest version instead of a stale copy.
aws cloudfront create-invalidation \
--distribution-id E123ABC \
--paths "/*"Quick Check
Test your static hosting knowledge.
Recap: Global Static Sites
You can now ship a static site on AWS:
- Enable S3 static website hosting with index/error documents.
aws s3 syncdeploys your build.- CloudFront adds edge caching, HTTPS, and custom domains.
- Use OAC to keep the bucket private and invalidate the cache on deploy.
よくある質問
「静的WebサイトのホスティングとCDN配信」レッスンは無料ですか?
はい。「静的WebサイトのホスティングとCDN配信」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、AWS for Backend Developers (EC2, S3, RDS, Lambda)コースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 AWS for Backend Developers (EC2, S3, RDS, Lambda)コースには全4レッスンが含まれています。
「静的WebサイトのホスティングとCDN配信」で何を学びますか?
S3バケットから静的Webサイトを直接配信し、その前段にCloudFront CDNを配置してグローバル配信を高速化します。 ブラウザで直接実行するハンズオンコードでAWS for Backend Developers (EC2, S3, RDS, Lambda)を演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
AWS for Backend Developers (EC2, S3, RDS, Lambda)を始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのAWS for Backend Developers (EC2, S3, RDS, Lambda)は初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「静的WebサイトのホスティングとCDN配信」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このAWS for Backend Developers (EC2, S3, RDS, Lambda)レッスンでコードを書いて実行できますか?
はい。すべてのAWS for Backend Developers (EC2, S3, RDS, Lambda)レッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- S3 バケットとオブジェクトの基礎
- S3 のバージョニングとライフサイクルポリシー
- S3 データアクセスの保護
- 静的WebサイトのホスティングとCDN配信