Websites & apps

Host a static website on S3-compatible storage with a CDN

Publish a static site (HTML, React or Hugo build) to an S3-compatible bucket, configure index and error pages, add a custom domain through a CDN with HTTPS and automate deploys.

IntermediateStatic websites2 min read

Sites built with static generators or single-page frameworks are just files. Static website hosting on S3 storage serves those files straight from a bucket, with a CDN in front for speed, HTTPS and a custom domain. There is no server to patch.

Before you start

  • An S3-compatible storage account that supports public buckets or website endpoints. See object storage explained.
  • A built site folder (e.g. dist/ or public/).
  • A domain and DNS access, and a CDN account.
  • A static site cannot run PHP or databases. For WordPress or PHP apps, use web hosting instead.

Create and configure the bucket

  1. Create a bucket, often named after the site (e.g. www.example.com).
  2. Enable the static website feature if the provider offers it, with index.html as index and 404.html as error document.
  3. Allow public read on objects, either through a bucket policy or by letting only the CDN read (preferred when supported).

Upload the site

With rclone (configured as in the rclone guide):

rclone sync ./dist s3backup:www.example.com --checksum

Or with the AWS CLI pointed at any S3 endpoint:

aws s3 sync ./dist s3://www.example.com --delete --endpoint-url https://s3.provider.example

Make sure files get correct Content-Type headers (most tools set them from file extensions).

Add a CDN, domain and HTTPS

  1. In the CDN, create a site or distribution with the bucket's website endpoint as origin.
  2. Add your domain and issue a free certificate through the CDN.
  3. Point DNS: a CNAME for www to the CDN hostname (apex domains need CNAME flattening or ALIAS records).
  4. Set caching: long cache for hashed assets, short cache for index.html.

See what is a CDN for how caching works.

Single-page apps

Client-side routes (e.g. /dashboard) do not exist as files. Configure the error document or a CDN rewrite to serve index.html for unknown paths.

Automate deploys

In CI, build the site, run the sync command with access keys stored as secrets, then purge the CDN cache for index.html.

Troubleshooting

  • 403 AccessDenied: objects are not publicly readable, or the CDN is not authorised.
  • Browser downloads HTML instead of showing it: wrong Content-Type.
  • Old version still shows: CDN cache; purge or use hashed filenames.

Frequently asked questions

Is static hosting free?

Storage and CDN costs are often very low for small sites, but check request and egress fees.

Can I add a contact form?

Use a third-party form service or a serverless function; see serverless explained.

Can I host a static site on cPanel instead?

Yes, upload the files to public_html with web hosting.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.