TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Hosting your static site with AWS S3, Route 53, and CloudFront for free

74 pointsby startupflixabout 7 years ago

16 comments

Zaheerabout 7 years ago
This isn't really free - it's just free for first year until your free tier runs out. It's still super cheap though. I host several sites with this setup and never have a bill over $2 / month. Benefit of this setup over github pages / netlify / etc is it uses standard primitives and will always exist. I used to use Heroku to host several sites and had to go through a massive migration when they stopped offering a free tier.
评论 #17008336 未加载
flotherabout 7 years ago
The article&#x27;s from December 2017 and you can see from the response headers that it&#x27;s hosted on GitHub Pages again.<p>There are plenty of gotchas when serving a static site via CloudFront. Let&#x27;s say you have a page at example.com&#x2F;foo&#x2F;index.html. If you want it serve it from example.com&#x2F;foo&#x2F; then you need to write a Lambda@Edge request function to handle the directory index — the article implies that CloudFront&#x27;s default root objects handle this, but they don&#x27;t. That&#x27;s for the domain root only.<p>There&#x27;s also the case of redirecting example.com&#x2F;foo to example.com&#x2F;foo&#x2F; (adding the trailing slash). That requires a Lambda@Edge response function. It&#x27;s all a lot of fun to get working, but you do start to wonder if your static site really is static.
评论 #17008519 未加载
评论 #17008966 未加载
评论 #17008249 未加载
roadbeatsabout 7 years ago
If this post gets very popular, we might see a second post from same author titled &quot;How CloudFront charged me 300$ in one day?&quot; :)
评论 #17008036 未加载
评论 #17008557 未加载
alban23about 7 years ago
Nice post. You can go one step further and automate most of the process with CloudFormation [1].<p>I also switched some time ago from Gitlab to CloudFront and S3 because it lets me optimize things that get you to 100% at Pagespeed Insights [2] such as Cache Control.<p>[1] <a href="https:&#x2F;&#x2F;correctme.ifiamwrong.com&#x2F;posts&#x2F;cloudfrontcloudformation&#x2F;" rel="nofollow">https:&#x2F;&#x2F;correctme.ifiamwrong.com&#x2F;posts&#x2F;cloudfrontcloudformat...</a> [2] <a href="https:&#x2F;&#x2F;developers.google.com&#x2F;speed&#x2F;pagespeed&#x2F;insights&#x2F;?hl=en" rel="nofollow">https:&#x2F;&#x2F;developers.google.com&#x2F;speed&#x2F;pagespeed&#x2F;insights&#x2F;?hl=e...</a>
deweyabout 7 years ago
Or just use Netlify or Github pages that also do that for free now and are as simple as pushing to your linked repository.
评论 #17007751 未加载
评论 #17007556 未加载
评论 #17007626 未加载
always_goodabout 7 years ago
I liked CloudFront until I realized that getting DDoSed also DDoSes your wallet.
评论 #17007886 未加载
评论 #17007967 未加载
amingilaniabout 7 years ago
Shameless plug, but if you&#x27;re trying to avoid eating into your free tier, I documented GitHub pages + Cloudflare for the same effect. Just turn your Cloudflare cache to super high, and GitHub shouldn&#x27;t ever get any real load.<p>I gave an example of running a React app[1]<p>[1]: <a href="https:&#x2F;&#x2F;www.toptal.com&#x2F;github&#x2F;unlimited-scale-web-hosting-github-pages-cloudflare#contract-just-respected-software-architects" rel="nofollow">https:&#x2F;&#x2F;www.toptal.com&#x2F;github&#x2F;unlimited-scale-web-hosting-gi...</a>
ernclabout 7 years ago
Sorry, these are terrible instructions. It would be good if someone with more experience could take another stab at this.
评论 #17007738 未加载
davidjnelsonabout 7 years ago
If you use cloudflare instead of cloudfront and route53, you don’t have to pay the $.50&#x2F;mo for dns, but much more importantly you get free bandwidth from cloudflare, and will pay next to nothing in s3 costs if you cache liberally with cloudflare at the cdn level.
bitmapbrotherabout 7 years ago
Requires a credit card to setup and you will be charged if your usage exceeds the free tier limit.<p><i>Please type your payment information so we can verify your identity. We will not charge you unless your usage exceeds the AWS Free Tier Limits.</i>
scarface74about 7 years ago
Your website doesn&#x27;t have to be static to host it for free on AWS. You can do server side stuff with Lambda and if you can get away with the 128MB instance (easy enough to do for one function) you get 1 million request a month for free and 888 hours of processing time. (<a href="https:&#x2F;&#x2F;aws.amazon.com&#x2F;lambda&#x2F;pricing&#x2F;" rel="nofollow">https:&#x2F;&#x2F;aws.amazon.com&#x2F;lambda&#x2F;pricing&#x2F;</a>). The free tier for Lambda doesn&#x27;t expire.<p>The only free hosted database that I am aware of is Mongo Atlas a 3 Node cluster with 500MB oh storage.
评论 #17010596 未加载
joobusabout 7 years ago
This setup isn&#x27;t free. The title is misleading.
andrewkslvabout 7 years ago
Why this stuff so complicated? Previously AWS has a link on the homepage where you could run a static website in couple clicks [1]. Now they removed it.<p>[1] <a href="https:&#x2F;&#x2F;console.aws.amazon.com&#x2F;quickstart-website&#x2F;home" rel="nofollow">https:&#x2F;&#x2F;console.aws.amazon.com&#x2F;quickstart-website&#x2F;home</a>
fsiefkenabout 7 years ago
If it&#x27;s low bandwidth and you have your own ip address you could also host on your own internet connection.
评论 #17007706 未加载
xz0rabout 7 years ago
Also make sure to set X-Frame-Options appropriately to avoid clickjacking! It is not set by default.
minicoolvaabout 7 years ago
I&#x27;m using firebase hosting and netlify