استضافة المواقع الثابتة وتسليمها عبر CDN
قدّموا موقعًا ثابتًا مباشرةً من حاوية S3، وسرّعوا التسليم عالميًا باستخدام CDN من CloudFront أمامها.
استضافة المواقع الثابتة وتسليمها عبر CDN درس مجاني في AWS for Backend Developers (EC2, S3, RDS, Lambda) على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في 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.
الأسئلة الشائعة
هل درس «استضافة المواقع الثابتة وتسليمها عبر CDN» مجاني؟
نعم — نص درس «استضافة المواقع الثابتة وتسليمها عبر CDN» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة AWS for Backend Developers (EC2, S3, RDS, Lambda)، انتقل إلى CoddyKit PRO. تتضمن دورة AWS for Backend Developers (EC2, S3, RDS, Lambda) 4 دروس في المجموع.
ماذا ستتعلم في «استضافة المواقع الثابتة وتسليمها عبر CDN»؟
قدّموا موقعًا ثابتًا مباشرةً من حاوية S3، وسرّعوا التسليم عالميًا باستخدام CDN من CloudFront أمامها. تتمرن على AWS for Backend Developers (EC2, S3, RDS, Lambda) مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ AWS for Backend Developers (EC2, S3, RDS, Lambda)؟
لا تُشترط خبرة سابقة. AWS for Backend Developers (EC2, S3, RDS, Lambda) على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «استضافة المواقع الثابتة وتسليمها عبر CDN»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس AWS for Backend Developers (EC2, S3, RDS, Lambda) هذا؟
نعم. كل درس في AWS for Backend Developers (EC2, S3, RDS, Lambda) يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- شرح حاويات وكائنات S3
- إصدار S3 وسياسات دورة الحياة
- تأمين الوصول إلى بيانات S3
- استضافة المواقع الثابتة وتسليمها عبر CDN