Nov 3, 2025 3 min read

How to Host Your Static Website on AWS S3 and CloudFront (Step-by-Step Guide)

How to Host Your Static Website on AWS S3 and CloudFront (Step-by-Step Guide)

🌍 Day 1 β€” Host a Static Website on AWS (S3 + CloudFront)

When I started my 30 Days of AWS Projects Challenge, I wanted to begin with something simple but powerful β€” a project that gives you a real-world AWS feel. So, I decided to host my first static website on AWS S3 and CloudFront.

This tutorial walks you through every step β€” from setting up your S3 bucket to making your site live worldwide with CloudFront and HTTPS. And yes, I’ll also show you how I fixed a 504 Gateway Timeout error that almost stopped me. πŸ˜…

πŸͺ£ Step 1: Create an S3 Bucket for Your Website

Amazon S3 is AWS’s storage service β€” but it can also serve as a simple web server for static files (HTML, CSS, JS).

Steps:

HTML example (save as index.html):

<html>
  <body style="text-align:center; font-family:sans-serif;">
    <h1>πŸš€ Hello from AWS S3 + CloudFront!</h1>
    <p>My first website hosted on Amazon S3</p>
  </body>
</html>

Now enable static website hosting:

http://joy-static-site-demo.s3-website.ca-central-1.amazonaws.com/

If you open this link, your site should load β€” public and live! πŸŽ‰

☁️ Step 2: Add CloudFront for Global Speed and HTTPS

CloudFront is AWS’s global CDN (Content Delivery Network). It caches your website content at edge locations around the world for faster delivery.

Steps:

Then open your CloudFront domain β€” something like:

https://dxxxxx.cloudfront.net

⚠️ Step 3: Fixing the 504 Gateway Timeout Error

When I tried to open my CloudFront link for the first time, I got this scary message:

504 Gateway Timeout ERROR

It turns out, CloudFront couldn’t talk to my S3 origin.

Cause:

Solution:

  1. Go to CloudFront β†’ Origins β†’ Edit Origin
  2. Replace the origin with your S3 website endpoint (should include s3-website)
  3. Set Origin protocol policy β†’ HTTP only
  4. Save, then go to Invalidations β†’ Create invalidation β†’ /*
  5. Wait 5–10 minutes and refresh

Result: Boom πŸ’₯ β€” site live globally with HTTPS.

πŸ’° AWS Cost and Free Tier Tips

Pro Tip: Delete your CloudFront distribution after the demo to avoid small background charges.

🧩 Architecture Diagram

User β†’ CloudFront (CDN) β†’ S3 Static Website

πŸ’‘ Key Takeaways

πŸ™‹β€β™‚οΈ FAQ (Highlighted)

🏁 Final Thoughts

Hosting your static website on AWS is the perfect starting point for anyone learning cloud. It’s simple, visual, and gives you that β€œI just deployed something real” feeling.

This was Day 1 of my AWS 30-Day Challenge β€” Next up β†’ Day 2: Launching a Web Server on EC2 πŸ–₯️

Liked this? Get more in your inbox.

One short email when I publish. AWS, AI, and founder notes β€” no spam, unsubscribe in one click.

By JOY 7Β months ago

// Read next

AWS EventBridge Explained: The Ultimate Q&A Guide for Developers (with Real-Life Examples)

# 🧩 AWS EventBridge Explained: The Ultimate Q&A Guide for Developers (with Real-Life Examples) ## 🧠 1. What …

AWS API Gateway: A Practical, Step-by-Step Guide

## πŸ”— What Is API Gateway? AWS API Gateway is the **entry point** for your backend APIs. It …

Building an AI Log Analyzer Using Hugging Face and FastAPI

# πŸš€ Building an AI Log Analyzer Using Hugging Face and FastAPI I’ve always been fascinated by the …