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.

Static site hosting hurdles

144 pointsby ciprian_craciunover 2 years ago

43 comments

chubotover 2 years ago
Uh what&#x27;s wrong with shared hosting? I use Dreamhost but there are dozens of others. It costs less than $10&#x2F;month and I&#x27;ve used it since 2009.<p>I think the industry (or part of a generation of programmers) somehow collectively forgot that it exists. I don&#x27;t see any mention of it in the article -- it solves the problem exactly. It easily serves and survives all the spikes from Hacker News that my site gets.<p>Shared hosting is a Linux box with a web server that someone ELSE manages. You get an SSH login, and you can use git and rsync.<p>It&#x27;s associated with PHP hosting, but it is perfect for static sites.<p><a href="http:&#x2F;&#x2F;www.oilshell.org&#x2F;blog&#x2F;2021&#x2F;12&#x2F;backlog-assess.html#appendix-shell-is-fast" rel="nofollow">http:&#x2F;&#x2F;www.oilshell.org&#x2F;blog&#x2F;2021&#x2F;12&#x2F;backlog-assess.html#app...</a><p>Answer to the HN question: <i>What&#x27;s the fastest way to get a page on the web</i>?<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29254006" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29254006</a><p>FWIW I also have a Linux VPS with nginx and a HTTPS certificate, but it&#x27;s a pain. I much prefer using shared hosting for things I want to be reliable.
评论 #32731982 未加载
评论 #32733796 未加载
评论 #32731863 未加载
评论 #32731272 未加载
评论 #32731178 未加载
评论 #32731087 未加载
评论 #32731415 未加载
评论 #32745591 未加载
评论 #32733825 未加载
akerl_over 2 years ago
It felt odd to see a doc this comprehensive on static site hosting with no mention of AWS S3&#x2F;Cloudfront, given how easy it is to push content to an S3 bucket (either manually or via the CI pipeline of your choosing) and then serve it up either direct-from-S3 or via Cloudfront.<p>But then it turns out that this is actually pushing folks towards some new paradigm of static cached HTTP responses instead of files. It pitches this as an attempt to “standardize the hosting side of static sites”, which doesn’t pass muster for me. We’ve already standardized the hosting side of static sites by using the file system. Shifting to a new storage format besides “HTML on disk” doesn’t unify anything, nor does it seem desirable to have fewer options for serving content.
评论 #32735077 未加载
评论 #32730641 未加载
评论 #32730540 未加载
评论 #32734261 未加载
评论 #32732259 未加载
chrismorganover 2 years ago
&gt; <i>check that with&#x2F;without .html extension serving works properly; (i.e. &#x2F;some-file.html should perhaps return the same content as &#x2F;some-file, or even better, choose one as canonical and redirect for the other one;)</i><p>Strong disagree. You do <i>not</i> want both URLs to return the same content; you <i>can</i> have alternatives redirect to the canonical URL; but think through why you’re doing it: who is benefited by the redirect?<p>If your canonical URL is &#x2F;example, I see no reason at all to support .html. If it’s &#x2F;example.html, I see no particular reason to support &#x2F;example or &#x2F;example&#x2F;. If it’s &#x2F;example&#x2F;, there <i>may</i> be a smidgeon of value in supporting &#x2F;example. If it’s &#x2F;example and you ever have paths below that (&#x2F;example&#x2F;example), then there may be slight value in supporting &#x2F;example&#x2F;.<p>If you switch from one format to another, do ensure that all existing URLs work. I used to use .html, so my old *.html URLs now redirect to *&#x2F;, but only for old articles, not new ones that were never .html, because I like being fancy like that.<p>But overall, I say: for at least the .html and trailing slash suffixes, no software should ever be causing these errors (I have heard rumours of improper transformations once or twice, but seen no evidence, and neither of these are ambiguous “will the automatic linkifier include or exclude that punctuation at the end” cases), so it’s all about humans and what incorrect URLs they might type out. And most of these sorts of things, people just won’t do.<p>Supporting more things for the sake of it is <i>not</i> a virtue. There is value in failing early on incorrect input. Postel was wrong.
评论 #32733880 未加载
furyofantaresover 2 years ago
&gt; the cloud operator, given that all of the above choices are self-hosted (or at least require some system administration skills), would immediately go for a hosted solution like CloudFlare Pages, Netlify, Vercel, or one of the source code hosting sites that also have static site hosting solutions like SourceHut pages or GitHub pages;<p>i think of myself as a graybeard (in the article&#x27;s parlance; i find the term exclusionary) and i use cloudflare in front of github pages. every year i&#x27;ve spent as this craft has seen me accumulate more than a year&#x27;s worth of new things i&#x27;d like to program or learn, 30 years in the list is very long. spending my time and energy doing IT for a static web site is a major waste
评论 #32733837 未加载
decasiaover 2 years ago
I guess everyone has their own solution to this. Here&#x27;s mine:<p>- Write some static html and one stylesheet<p>- Pay DigitalOcean for the cheap plan<p>- Run nginx + letsencrypt<p>- Apply linux security updates promptly<p>- Occasionally pay to renew the domain<p>So yeah, that does take a little bit of (very simple) systems administration skills, and it&#x27;s a recurring commitment. But there is no such thing as a successful but unmaintained web site. Even if you don&#x27;t have to maintain the infrastructure, you have to maintain the content. So I don&#x27;t mind the occasional maintenance tasks. They keep me in touch with linux systems administration in a good way.<p>It&#x27;s cool to write your own web server software, I guess. But serving static html is pretty much a solved problem. I felt like the OP was inventing problems with it that don&#x27;t really exist in practice.
评论 #32732055 未加载
评论 #32731120 未加载
triknomeisterover 2 years ago
Static hosting on VPS cite is easy as hell. Get a VPS with Ubuntu 22.04 for as low as 3 Euros&#x2F;Month, execute the following commands:<p>```<p>sudo apt-get install -y nginx python3-certbot-nginx certbot sudo ufw allow &quot;Nginx Full&quot; sudo unlink &#x2F;etc&#x2F;nginx&#x2F;sites-enabled&#x2F;default sudo mkdir -p &#x2F;srv&#x2F;https&#x2F;website sudo chown -vR $MYUSER:$MYUSER &#x2F;srv&#x2F;https&#x2F;website<p>echo &quot;I&#x27;ve created my website here.&quot; &gt; &#x2F;srv&#x2F;https&#x2F;website&#x2F;index.html<p>cat &gt; conf &lt;&lt;- EOM server { listen 80; listen [::]:80;<p><pre><code> root &#x2F;srv&#x2F;https&#x2F;website; index index.html; server_name $URL; location &#x2F; { try_files \$uri \$uri&#x2F; =404; }</code></pre> } EOM<p>sudo cp config &#x2F;etc&#x2F;nginx&#x2F;sites-available&#x2F;website sudo ln -s &#x2F;etc&#x2F;nginx&#x2F;sites-available&#x2F;website &#x2F;etc&#x2F;nginx&#x2F;sites-enabled&#x2F;website sudo certbot --nginx -n -d $URL --agree-tos --redirect -m $EMAIL --webroot -w &#x2F;srv&#x2F;https&#x2F;website ```<p>Setup your DNS to the IP of VPS and you&#x27;re done setting up your static website. Updates now are just `rsync`
评论 #32736407 未加载
评论 #32735497 未加载
esperentover 2 years ago
I switched from Vercel static site hosting, because I recently read an article here about how it&#x27;s usually more economical to scale vertically instead of horizontally (i.e. use one big server for everything).<p>Even though I&#x27;m only running a few services, I did the math and realized it&#x27;s absolutely true. I can fit everything I&#x27;m running onto one DigitalOcean droplet behind Cloudflare for $24&#x2F;month + an extra 25gb block storage for $2.5&#x2F;month + $5&#x2F;month for backblaze backups.<p>Everything being: a bunch of static sites, Keycloak Auth, Rocket.Chat, Odoo business management software, Nginx Proxy Manager, Outline (self hosted Notion), Docker, Portainer, Cockpit, Listmonk.<p>Static sites are free actually, besides storage. You can just add a location directive pointing to the folder in Nginx Proxy Manager and it&#x27;ll serve the files for you.<p>The biggest memory hog is Keycloak which is a Java app so it uses 700mb of ram.<p>But in any case I have set up an entire small business software suite with a hosting cost of $31.5 and I can host unlimited static sites with no additional cost.
评论 #32735600 未加载
评论 #32732016 未加载
habiburover 2 years ago
There&#x27;s also HTTP HEAD requests, and &quot;304 Not Changed&quot; that you need to take care of. This is what makes static site download look instantaneous. There&#x27;s more of such optimizations.<p>With all these I find it better to stick with old Apache or similar service for speed, rather than a simpler service that only takes care of GET.
评论 #32733501 未加载
评论 #32731528 未加载
DanHultonover 2 years ago
Just because there are a lot of options, doesn&#x27;t make something complicated. Hosting a static site - arguably the simplest kind of site - could be easily done with any of the options listed and derided at the start of the article.
tomcamover 2 years ago
Sobering, eye-opening, and encouraging in one swell foop. I am bookmarking &amp; backing this page up because it coalesces many many issues that have been plaguing me with static site generation.<p>Well done.
dragontamerover 2 years ago
I&#x27;m very confused by this entire post.<p>No mention of neocities or shared&#x2F;managed hosts (Namecheap or even GoDaddy?)<p>I mean, I know we nerds look down upon GoDaddy and other such sites, but it&#x27;s cheaper than setting up a VPS and good enough for any static site.
bsuvcover 2 years ago
GitHub Pages works well for me.<p><a href="https:&#x2F;&#x2F;pages.github.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pages.github.com&#x2F;</a>
jonathantf2over 2 years ago
One of the features I don&#x27;t think Fastmail advertise at all is that you can host static websites from your user storage - with HTTPS etc. You can use one of their subdomains or your own domain, it can do photo galleries I think as well as redirects.
joelbermanover 2 years ago
Last month I paid $1 for route53, 12 cents for S3. and am hosting my https site which I create with publii. Works fine. Took a little time to set up, but now it is just a button push to update the site. Great for my personal blog and phtot gallery.
评论 #32731538 未加载
forrestthewoodsover 2 years ago
Yeah I went with Netlify for my static site because I have zero desire to ever been an IT admin.<p>I do skip the static generator part and go with artisinally hand crafted HTML&#x2F;CSS&#x2F;JS instead. It’s radically simpler and ultimately better imho.
评论 #32735582 未加载
评论 #32734219 未加载
pSYoniKover 2 years ago
I just use a VPS, Caddy with a 10 line Caddyfile and scp my html on to the machine.<p>I don&#x27;t find any real hurdles here and the only thing running on the server is Caddy to serve the content on https&#x2F;http. Anything that&#x27;s not a valid path returns a 404 custom page I made and that&#x27;s it.<p>To get my HTML I use Hugo locally, but I&#x27;m not a huge fan of Hugo itself due to it&#x27;s documentation which cannot be followed linearly and I plan on writing something to do just this - convert some markdown files and a folder structure to an HTML. I&#x27;m sure such a tool already exists but I&#x27;m curious about building something like this myself.<p>I think the hurdles appear depending on what you expect or want to do with your static page, but the base setup is I think pretty straightforward.
quickthrower2over 2 years ago
I read this as:<p>The problem is there are 99 ways to do to it from sysadmin-y to cloud-y.<p>My solution is to add 100th way.<p>——-<p>If static hosting is hard use Netlify or similar. Just point it at your Github and you are done!<p>They mentioned Netlify.
dustedover 2 years ago
This is less of an article, and more of an advertisement for cloudflare..<p>No, you don&#x27;t need a CDN for your lightweight static site. nginx and your home fiber gigabit connection will do _JUST_FINE_ (tm), even when slashdotted or getting on frontpage at HN.<p>Also, just drop the generators and write your html already.. Sure, it&#x27;s fun to learn a new toy, but in end, any abstraction between your content and the HTML being served is just another link in the chain of things that can break.<p>Organize your HTML files well, use minimal styling and it becomes quite managable, you literally don&#x27;t have a technology stack.. just dump the files on ANYTHING IN THE UNIVERSE that has a webserver and a file system, and you&#x27;re good to go.
评论 #32734066 未加载
评论 #32733624 未加载
Aldipowerover 2 years ago
One forgotten hurdle of static site hosting is in-memory caching. At most http-server default setup each request goes down to the filesystem. Mostly your are lucky and your filesystem itself has some kind of caching mechanism, so you won&#x27;t notice. But if your static site ends up in a &quot;very high requests&quot; situation, you should think about in-memory caching of your static files.
评论 #32734203 未加载
mymythisisthisover 2 years ago
I&#x27;d be nice to run a self-hosted site from a home server. Currently paying a third party for a static site, but space is so limited. Storage space isn&#x27;t that expensive, until you have to pay monthly for it. Mostly just want to host my own pictures.<p>Would really like a hands on workshop to learn to do it (how to get a static IP, setup everything correctly, how to use https).
评论 #32731172 未加载
评论 #32736912 未加载
luniasover 2 years ago
It costs me about 1 dollar a month (never more than 2 dollars) to host my website.<p>I use:<p>- VuePress<p>- Amazon S3<p>- Amazon Certificate Manager<p>- Amazon CloudFront<p>- Amazon Route53<p>For deployment:<p>- CircleCI<p>- s3deploy<p>It&#x27;s a super simple (and cheap) setup. Just push a commit and the site gets updated.
评论 #32733474 未加载
throwaway892238over 2 years ago
Why would you ever host a static site yourself? There is nothing special about it, it&#x27;s just text. Use any of the dozen different free static site hosters.<p>If you&#x27;re just trying to learn web server tech, then do it all yourself, but jump through the hoops too; don&#x27;t use a tool that does it all for you, that defeats the purpose.
fallatover 2 years ago
Ok so let&#x27;s make a UI that asks for your credit card and which host you want... This has nothing to do with the web servers IMO. Even if we give people the configuration done there will still be other issues. It has to be as easy as pressing one &quot;go online&quot; button, really.
free652over 2 years ago
Cloudflare has free hosting for static content. there are some limits, but my sites are tiny.
评论 #32734140 未加载
jacooperover 2 years ago
I think these issues only exist if you decided to host the site yourself, I did and currently optimizing Caddy settings, but kawipiko surely seems interesting, however I use caddy as a reverse proxy too, so I can&#x27;t switch.<p>If you just to chose to use Cloudflare Pages you will get the best settings, and performance by default, its effortless.<p>I self host because Cloudflare already has enough control on the internet, it serves more than 20% of the web!<p><a href="https:&#x2F;&#x2F;w3techs.com&#x2F;technologies&#x2F;history_overview&#x2F;web_server" rel="nofollow">https:&#x2F;&#x2F;w3techs.com&#x2F;technologies&#x2F;history_overview&#x2F;web_server</a>
gammanover 2 years ago
I wonder if HTTP exchanges &#x2F; Web Bundles (from the Web Packaging proposal) would bring the approach of statically generating request-response pairs more to the mainstream.<p>If I understand correctly, then with both hosting and browser support for Web Packaging proposal, one could even statically pregenerate the whole signed exchange or bundle and skip the server-side TLS part as well.<p>The whole certificate renewal process will probably make that last part nonviable.<p>Not considering other potential effects on the web if the proposal gets adopted of course.
Helmut10001over 2 years ago
Strange that a pretty common way to serve static sites is not mentioned: Multi-stage Docker builds [e.g. 1] an nginx-alpine image in Gitlab CI, that is automatically deployed to Kubernetes&#x2F;a Docker host somewhere. Add the Let&#x27;s Encrypt Container for automatic SSL.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;lewish&#x2F;asciiflow&#x2F;blob&#x2F;fd0f72714cd307cbb02cf98d708fdd79c1c22f4e&#x2F;Dockerfile" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lewish&#x2F;asciiflow&#x2F;blob&#x2F;fd0f72714cd307cbb02...</a>
评论 #32733340 未加载
gratonover 2 years ago
I am currently using GitLab to do my static site hosting for free using their pages feature. And I get to use my own domain name and have SSL&#x2F;https support automatically.
cobertosover 2 years ago
I&#x27;ve also come across <a href="https:&#x2F;&#x2F;staticdeploy.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;staticdeploy.io&#x2F;</a> which is self hosted and more akin to something like Vercel which manages a bit more than just serving&#x2F;hosting.<p>Too bad it doesn&#x27;t seem fully baked. I love the workflow of Vercel with the auto deployments from git and the infinite deploys via tags. Haven&#x27;t found a good self-hosted alternative yet.
rozenmdover 2 years ago
With wrangler2 (<a href="https:&#x2F;&#x2F;github.com&#x2F;cloudflare&#x2F;wrangler2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cloudflare&#x2F;wrangler2</a>) you can deploy a static site to Cloudflare for free (you don&#x27;t get any of the features of Cloudflare Pages though):<p>echo &#x27;# Hmm&#x27; &gt; index.md<p>npx @11ty&#x2F;eleventy<p>npx wrangler publish --assets _site&#x2F; --name name-of-static-website --latest
idealmedtechover 2 years ago
Quick but important note: for those who don&#x27;t know already, Volution sells a square space-esque managed site builder with hosting, which means this post does have a minor conflict of interest (although these days I guess it&#x27;s called content marketing). Haven&#x27;t seen it mentioned yet in the comments.
评论 #32733590 未加载
Syeposxrover 2 years ago
What&#x27;s wrong with Netlify or Surge.sh?
preseingerover 2 years ago
fasthttp doesn&#x27;t implement HTTP&#x2F;1 correctly, and doesn&#x27;t implement HTTP&#x2F;2 at all. It&#x27;s not an appropriate choice for a general purpose tool or library. The code is also not correctly formatted. Strong negative signals.
评论 #32733632 未加载
Havocover 2 years ago
There is another easy option: BunnyCDN. You can just drop the files on there via ftp.
cloudyporpoiseover 2 years ago
Any simple thing can be made overly complex. If you&#x27;re dealing with a truly simple static site, upload your client-side code to Netlify and call it a day. If you want more control, then it will come with more complexity.
longrodover 2 years ago
The article is right in that setting up a server for any kind of hosting is not a simple task. There are no &quot;good defaults&quot; or &quot;templates&quot; easily embeddable&#x2F;extendible for your specific use-case.
quintussssover 2 years ago
I use a static site generator, a vps and a git post-receive hook to build and deploy my site. Does not require any third-party providers (apart from the vps) and takes about 15 minutes to setup.
schemescapeover 2 years ago
Are there any static hosts that provide HTTP logs?<p>I know it’s not perfect, but I want to have some sort of analytics without trackers.
评论 #32733993 未加载
评论 #32745560 未加载
ThinkBeatover 2 years ago
apt install apache2 mkdir &#x2F;var&#x2F;www&#x2F;your_domain cp &#x2F;home&#x2F;a&#x2F;website &#x2F;var&#x2F;www&#x2F;your_domain
nathantsover 2 years ago
don’t forget to add cloudflare workers + r2. the best parts of lambda and s3, without the egress billing.
评论 #32730989 未加载
bandramiover 2 years ago
Not mentioning S3 here seems weird
em1sarover 2 years ago
&gt;hosting these static sites, and we are still in the early 2000s eh no?
ibn_khaldunover 2 years ago
This is a very good white paper.