Statische Websites hosten und per CDN ausliefern
Liefern Sie eine statische Website direkt aus einem S3-Bucket aus und beschleunigen Sie die globale Bereitstellung mit einem vorgeschalteten CloudFront-CDN.
Statische Websites hosten und per CDN ausliefern ist eine kostenlose AWS for Backend Developers (EC2, S3, RDS, Lambda)-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des AWS for Backend Developers (EC2, S3, RDS, Lambda)-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der AWS for Backend Developers (EC2, S3, RDS, Lambda)-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
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.
Häufig gestellte Fragen
Ist die Lektion „Statische Websites hosten und per CDN ausliefern“ kostenlos?
Ja — der vollständige Text von „Statische Websites hosten und per CDN ausliefern“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des AWS for Backend Developers (EC2, S3, RDS, Lambda)-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der AWS for Backend Developers (EC2, S3, RDS, Lambda)-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Statische Websites hosten und per CDN ausliefern“?
Liefern Sie eine statische Website direkt aus einem S3-Bucket aus und beschleunigen Sie die globale Bereitstellung mit einem vorgeschalteten CloudFront-CDN. Du übst AWS for Backend Developers (EC2, S3, RDS, Lambda) mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um AWS for Backend Developers (EC2, S3, RDS, Lambda) zu starten?
Keine Vorkenntnisse erforderlich. AWS for Backend Developers (EC2, S3, RDS, Lambda) auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Statische Websites hosten und per CDN ausliefern“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser AWS for Backend Developers (EC2, S3, RDS, Lambda)-Lektion Code schreiben und ausführen?
Ja. Jede AWS for Backend Developers (EC2, S3, RDS, Lambda)-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- S3-Buckets und Objekte erklärt
- S3-Versionierung und Lebenszyklusregeln
- S3-Datenzugriff absichern
- Statische Websites hosten und per CDN ausliefern