Host a Static Website on S3 with CloudFront and a Private Bucket
Amazon S3 can store a static site’s HTML, CSS, JavaScript and images. It does not execute PHP or run a normal WordPress application. Build or export the static files before following this workflow.
This walkthrough uses a private S3 bucket as a CloudFront origin. It keeps S3 Block Public Access enabled and serves public site files through CloudFront over HTTPS. It does not use the bucket’s website endpoint.
1. Prepare a clean static build
Test the build locally. Include the intended index.html, assets and an appropriate not-found response. Exclude secrets, credentials, private uploads and source files that should not be published.
Check links and actual file paths. An exported page at about/index.html does not automatically establish every desired clean-URL behaviour at the delivery layer.
2. Create the S3 bucket
In the intended AWS account and region, create a bucket using appropriate ownership and access settings. Keep public access blocked. Upload the static build with correct content types.
AWS’s static-hosting overview explains S3’s website capabilities. Here, the bucket is object storage behind CloudFront; enabling S3 website hosting is unnecessary.
3. Create the CloudFront distribution
Select the S3 bucket’s regular REST origin, not its website endpoint. Configure origin access control, or OAC, with the recommended request-signing arrangement.
Follow the official OAC guide to grant the specific distribution permission to read the required objects. Review the resulting bucket policy instead of adding a wildcard public-read policy.
4. Configure HTTPS and the root document
Use an appropriate viewer policy to require HTTPS or redirect HTTP viewers to HTTPS. Set the default root object to index.html, without a leading slash.
The default-root-object documentation distinguishes the distribution root from subdirectory behaviour. Design the build or routing explicitly for nested paths rather than assuming this one setting resolves them.
5. Test the distribution before connecting a domain
After deployment, visit the distribution hostname. Check the homepage, CSS, images, nested pages and a missing path. Verify that anonymous direct access to the bucket’s objects remains denied while the distribution can serve the intended public files.
A useful test includes the actual HTTP response as well as the visible page. Do not turn every missing page into a successful response merely to hide a routing error.
6. Add a custom domain if needed
Configure the alternate domain, a compatible certificate and the required DNS record using the current CloudFront instructions. Wait for the distribution and certificate state to be ready, then test the final hostname and HTTPS.
Keep the old site available during a planned migration and preserve relevant redirects. The migration checklist helps coordinate the wider cutover.
7. Plan updates, recovery and cost
Set caching rules appropriate to the files. Versioned asset filenames help publish changed assets without relying on every cache expiring simultaneously. Verify a correction reaches the delivered site and use supported invalidation where required.
Retain a known-good build and a tested rollback route. Estimate S3 storage and requests, CloudFront delivery and requests, logs and any extra features. Do not promise free hosting or universal savings.
This is public content delivered from a private origin, not access control for confidential files. Use the DNS guide for record changes and the security routine for account and deployment access.








