News for hackers. Stuff that matters.
Re:A tiny Docker image to serve static websites by mg on Tuesday April 12, 2022 @01:02PM (#31005346)
For static websites, is there any reason not to host them on GitHub?

Since GitHub Pages lets you attach a custom domain, it seems like the perfect choice.

I would expect their CDN to be pretty awesome. And updating the website with a simple git push seems convenient.

Re:A tiny Docker image to serve static websites by naet on Tuesday April 12, 2022 @02:40PM (#31006704)
Once you've used a couple more static hosts you'll find that gh pages is a second tier host at best. Lacks some basic configuration options and toolings, can be very slow to update or deploy, the cdn actually isn't as good as others, etc. Github pages is great for hobby projects and if you're happy with it by all means keep using it... but I wouldn't ever set up a client's production site on it.

If you're curious, Netlify is one popular alternative that is easy to get in to even without much experience. I would say even at the free tiers Netlify is easily a cut above Github for static hosting, and it hooks into github near perfect straight out of the box if that is something you value.

Re:A tiny Docker image to serve static websites by jason0597 on Tuesday April 12, 2022 @01:48PM (#31006006)
> is there any reason not to host them on GitHub?

Because some people may not want to depend even more on Big Tech (i.e. Microsoft) than they already do

Re:A tiny Docker image to serve static websites by _-david-_ on Tuesday April 12, 2022 @01:36PM (#31005835)
>For static websites, is there any reason not to host them on GitHub?

One reason would be if your site violates the TOS or acceptable use policy. GitHub bans "excessive bandwidth" without defining what that is for example. For a small blog about technology you are probably fine.

Re:A tiny Docker image to serve static websites by marginalia_nu on Tuesday April 12, 2022 @02:01PM (#31006182)
Wanting to own your own web presence is reason not to host them on GitHub.

For static websites, CDNs are largely unnecessary. My potato of a website hosted from a computer in my living room has been on the front page of HN several times without as much as increasing its fan speed.

It took Elon Musk tweeting a link to one of my blog posts before it started struggling to serve pages. I think it ran out of file descriptors, but I've increased that limit now.

Re:A tiny Docker image to serve static websites by flatiron on Tuesday April 12, 2022 @08:17PM (#31009759)
Was it through a VPN? I feel like revealing my home IP to random people on the internet is a bad move.
Re:A tiny Docker image to serve static websites by marginalia_nu on Wednesday April 13, 2022 @04:36AM (#31012399)
No VPN. I have the ports fairly well tightened down, though. I'm exposed to a zero-day in iptables itself or something, but whatever. Even if someone got in it would be an inconvenience at worst. It's not like I'm making money off this stuff.
Re:A tiny Docker image to serve static websites by lostlogin on Tuesday April 12, 2022 @02:19PM (#31006437)
Are you able to describe how you run yours? I scummed your blog but didn’t see anything about it.
Re:A tiny Docker image to serve static websites by marginalia_nu on Tuesday April 12, 2022 @02:29PM (#31006560)
The static content is just nginx loading files straight off a filesystem. The dynamic content (e.g. the search engine) is nginx forwarding requests to my Java-based backend.
Re:A tiny Docker image to serve static websites by Dma54rhs on Tuesday April 12, 2022 @08:49PM (#31009978)
You can serve massive amount of static requests from any potato really, it's a solved problem.
Re:A tiny Docker image to serve static websites by throwaway894345 on Tuesday April 12, 2022 @01:09PM (#31005440)
I'm sure their CDN is great, and I've used it in the past; however, I like to self-host as a hobby.
Re:A tiny Docker image to serve static websites by enriquto on Tuesday April 12, 2022 @02:17PM (#31006411)
> For static websites, is there any reason not to host them on GitHub?

I don't like github pages because it's quite slow to deploy. Sometimes it takes more than a couple of minutes just to update a small file after the git push.

Re:A tiny Docker image to serve static websites by qbasic_forever on Tuesday April 12, 2022 @01:08PM (#31005427)
I don't think you can set a page or URL on github to return a 301 moved permanently response or similar 3xx codes. This can really mess up your SEO if you have a popular page and try to move off github, you'll basically lose all the clout on the URL and have to start fresh. It might not matter for stuff you're just tossing out there but is definitely something to consider if you're putting a blog, public facing site, etc. there.
Re:A tiny Docker image to serve static websites by nobodywasishere on Tuesday April 12, 2022 @01:12PM (#31005468)
I have a few 301 redirects setup on github pages

    $ curl https://nobodywasishere.github.io # moved to https://blog.eowyn.net

    <html>
    <head><title>301 Moved Permanently</title></head>
    <body>
    <center><h1>301 Moved Permanently</h1></center>
    <hr><center>nginx</center>
    </body>
    </html>

    $ curl https://blog.eowyn.net/vhdlref-jtd # moved to https://blog.eowyn.net/vhdlref

    <html>
    <head><title>301 Moved Permanently</title></head>
    <body>
    <center><h1>301 Moved Permanently</h1></center>
    <hr><center>nginx</center>
    </body>
    </html>
Re:A tiny Docker image to serve static websites by qbasic_forever on Tuesday April 12, 2022 @01:16PM (#31005530)
Is that coming back with a HTTP 200 response though and the made up HTML page? That doesn't seem right... at least, I dunno if google and such would actually index your page at the new URL vs. just thinking "huh weird looks like blog.eowyn.net is now called '301 Moved Permanently', better trash that down in the rankings".
Re:A tiny Docker image to serve static websites by cptskippy on Tuesday April 12, 2022 @01:20PM (#31005589)
It shows up as a proper 301 when I load up the URL in Firefox. The question is, how?
Re:A tiny Docker image to serve static websites by MD87 on Tuesday April 12, 2022 @01:28PM (#31005705)
One of the Jekyll plugins that GH Pages supports[0] is jekyll-redirect-from, which lets you put a `redirect_to` entry in a page's front matter.

[0]: https://pages.github.com/versions/

Re:A tiny Docker image to serve static websites by simonw on Tuesday April 12, 2022 @10:03PM (#31010446)
I found this example of another repo that is using the same trick: https://github.com/kotokaze/kotokaze.github.io

    ~ % curl -i 'https://kotokaze.github.io/'
    HTTP/2 301 
    server: GitHub.com
    content-type: text/html
    permissions-policy: interest-cohort=()
    location: http://github.kotokaze.net/
Re:A tiny Docker image to serve static websites by nobodywasishere on Tuesday April 12, 2022 @06:11PM (#31008880)
For the latter, `<meta http-equiv="refresh" content="0; URL=https://blog.eowyn.net/vhdlref" />` in the `<head>`
Re:A tiny Docker image to serve static websites by qbasic_forever on Tuesday April 12, 2022 @01:23PM (#31005638)
Wow, nice yeah I'd love to know how github supports configuring a URL to 301 redirect!
Re:A tiny Docker image to serve static websites by chabad360 on Tuesday April 12, 2022 @01:20PM (#31005595)
Yea, no.

A 301 (or 302) redirect means setting the status code header to 301 and providing a location header with the place to redirect to. Last I checked GitHub doesn't allow any of this, or setting any other headers (like cache-control). To work around this, I've been putting cloudflare in front of my site which lets me use page rules to set redirects if necessary.

Re:A tiny Docker image to serve static websites by marban on Tuesday April 12, 2022 @01:18PM (#31005551)
Netlify FTW — For the rewrite rules alone.
Re:A tiny Docker image to serve static websites by coding123 on Tuesday April 12, 2022 @01:10PM (#31005456)
Well, not everything is open source.
Re:A tiny Docker image to serve static websites by tekromancr on Tuesday April 12, 2022 @01:03PM (#31005363)
Can you do SSL?
Re:A tiny Docker image to serve static websites by dewey on Tuesday April 12, 2022 @01:06PM (#31005409)
Yes, since 2018.