4 ms·
Use App Engine and Go to Host a Static Website with Same Domain Redirects
- bjpirt 10y agoOr even simpler you can use S3 redirects to send all of your old URLs to their new location on the same host. I'm currently doing this from both an old domain to a new domain and within the same domain and "It Just Works" (tm)
- tyingq 10y agoThrifty way to do this. Seems the golang code, though, isn't setting any expires or cache-control headers (for the static content it's serving), so your browser ends up re-downloading a lot of assets that it doesn't need to. Might be nice to add that bit in. Better performance for visitors, and would keep you in the free tier longer if traffic grows.
- aliasnexus0 10y agoYou are correct, and great points. This is my first Golang app, so doing what you suggested is my next step. Thanks!
- chrisp_dc 10y agoI host my static website using Firebase and Google Domains. Google has easy integration between the two and seems to include all the listed benefits out-of-box.
- type0 10y agoOften when I recommend GAE to someone the answer is: "but it's Google they are known to abandon their services". That and also the fear of being locked into Googles Cloud ecosystem pushes many potential customers away.
- wsh91 10y agoGAE gives at least a year after deprecation before turning off a feature. https://cloud.google.com/appengine/docs/deprecations/ https://cloud.google.com/appengine/docs/deprecations/ (I work on Google Cloud and on Datastore, which is built into App Engine. We bend over backwards to support existing code.)
- iamgopal 10y agoMy seven year old website work without single line of code since, so I know this is true.
- briandoll 10y agoOr just use Netlify: https://www.netlify.com/ https://www.netlify.com/
- StavrosK 10y agoSeconded, lately I've been using Lektor+netlify for all my sites. Deploying is just a git push, and it's zero-headache. Greatly recommended.
- caleblloyd 10y agoMy recommendation to a friend for static hosting would be to use shared hosting for $5/mo. Pick one that does automatic SSL with LetsEncrypt. I'm partial to Dreamhost because I've been on them for many years, but there are lots of good ones out there.
- kej 10y agoI know $5/month isn't all that much, but I still like to suggest Nearly Free Speech. Most static sites can be hosted for pennies per month.
- PuffinBlue 10y agoThis is well done. If you want it 'done for you' or have a site that doesn't fit in the free tier on GAE but don't want to spend money - take a look at Netlify. Free tier is generous, has CDN, free auto-provisioned SSL, builds automatically from a git repo (GitHUb/GitLab etc) and you can simply upload a _redirects file to handle redirects[0]. It'll even build a 'preview' of a branch, so just create a branch, make your changes and merge request, then Netlify will build a temporary site to view the changes - useful if you need to show someone what the changes to the site will look like. I just switched from GitLab pages, and even changed domain from the apex to www (to get full DDoS/CDN benefit out of Netlify this is needed) - which is handled automatically. If you want to have a poke around/speedtest of a site using it I'll link below[1]. [0] https://www.netlify.com/docs/redirects/ https://www.netlify.com/docs/redirects/ [1] https://www.josharcher.uk https://www.josharcher.uk
- grw_ 10y agoThe app.yaml routing allows "fall-through" routing, where your application's handler is only invoked if no static files match: - url: /static static_dir: static/ - url: /.* script: _go_app The redirect 'map' smells bad- better to simply serve the file if path exists, redirect if it doesn't.
- james_niro 10y agoI prefer Heroku over google cloud, better documentation and deploying is really easy.
- PuffinBlue 10y agoAny time I hear 'Heroku' it's mentally followed by that 'it's going to be expensive' intake of air sound. Is that prejudgement borne out in reality?
- tyingq 10y ago$7 a month for the hobby plan doesn't seem that terrible. But, serving static assets from Ruby seems heavy handed. You also end up writing code for things other environments would handle with configuration...like redirects, cache headers, and so forth. Also, while $7 isn't a lot, it is a little more than other solutions in this hobby level space. The suggestions for Netlify and Firebase seem better ideas for static content, and both allow for changing configuration instead of coding to satisfy the normal things you do for static assets. Both appear to be free at this hobby level as well.
- kristianp 10y agoYou can use Go with Heroku, with a buildpack [1]. There's a free plan, but it doesn't include SSL. [1] https://github.com/heroku/heroku-buildpack-go https://github.com/heroku/heroku-buildpack-go
- tyingq 10y agoThe free plan also "sleeps" after inactivity, right? I assume that means a really long page load for the visitor that follows the inactivity? And, you're still left implementing caching, redirects, etc, in a language (Go or Ruby) vs configuration directives. Just seems a poor option compared to other choices, at least for static content.
- nodesocket 10y agoHeads up Google Cloud just release a new feature today which allows you to redirect traffic to different storage buckets and even VM instances using simple rules which are themselves stored in a storage bucket. https://cloud.google.com/compute/docs/load-balancing/http/using-http-lb-with-cloud-storage?utm_source=release-notes&utm_medium=email&utm_campaign=2017-March-release-notes-1-en https://cloud.google.com/compute/docs/load-balancing/http/us...