Migrating from Codeberg Pages to an OpenBSD VPS
Migrating from Codeberg Pages to an OpenBSD VPS
从 Codeberg Pages 迁移至 OpenBSD VPS
In this post I’d like to explain the “how”-s and “why”-s of moving from forge-based static site hosting to a full on VPS. This isn’t really a tutorial, mostly because there are far better texts out there how one would do these things, but I do link to many of them and point out stuff I found confusing or surprising. Also, if you’re reading this post, you’re reading it served by the VPS, say hi!
在这篇文章中,我想解释一下从基于代码托管平台的静态网站托管迁移到完整 VPS 的“方法”和“原因”。这并不是一篇严格意义上的教程,主要是因为市面上已经有太多比这更好的指南了,但我会链接到其中的许多内容,并指出我发现令人困惑或惊讶的地方。另外,如果你正在阅读这篇文章,说明它是由 VPS 提供的,打个招呼吧!
1 Background
1 背景
I’ve been blogging for almost eight years now and for those eight years, I’ve always relied on some sort of free host for my content. This seemed fine for a pretty long time, especially considering neither this nor my other site is monetized at all. However, recent-ish changes in my needs and financial situation finally got me to break with the status quo and actually experiment a little.
我写博客已经快八年了,在这八年里,我一直依赖某种免费主机来托管我的内容。在很长一段时间里,这似乎都没什么问题,尤其是考虑到这个网站和我的其他网站完全没有盈利。然而,最近我的需求和财务状况发生了一些变化,最终促使我打破现状,进行了一些尝试。
Originally, I relied on Github Pages, which was for a site like mine almost perfect. It was free and required nearly zero setup, it built almost immediately, it had impeccable uptime (something Github famously started to struggle with), and I could super easily place a cheap domain in front of it to make it a little more appealing than the factory-default nemin32.github.io address.
最初,我依赖 Github Pages,对于像我这样的网站来说,它几乎是完美的。它免费且几乎不需要任何设置,构建速度极快,拥有无可挑剔的在线时间(这是 Github 后来开始出现问题的著名痛点),而且我可以非常轻松地在它前面放置一个廉价域名,使其看起来比默认的 nemin32.github.io 地址更具吸引力。
However, due to the, ehm, recent trends and emboldened by the rallying cries of the people who had enough, I too took the dive and moved my presence over to Codeberg. This, of course, meant my two websites had to move too. Thankfully the process wasn’t particularly painful (the article linked above pretty much gets you up to speed in 10-15 minutes) and so I quickly had everything set up.
然而,由于最近的一些趋势,加上那些受够了的人们的呐喊,我也下定决心,将我的阵地转移到了 Codeberg。当然,这意味着我的两个网站也必须随之迁移。幸运的是,这个过程并不特别痛苦(上面链接的文章基本上能在 10-15 分钟内让你上手),所以我很快就完成了所有设置。
While I thought I was done, sadly I quickly realized that though the two services were similar in design, their quality of service was very different. Codeberg Pages really struggled at times. My pages are rarely over a couple hundred kilobytes (most of which being a couple AVIF-encoded pictures) and yet there were times where loading my sites took 10-15 seconds, while the browser just hanged.
虽然我以为大功告成,但遗憾的是,我很快意识到尽管这两项服务在设计上相似,但它们的服务质量却大相径庭。Codeberg Pages 有时确实很吃力。我的页面很少超过几百 KB(其中大部分是几张 AVIF 编码的图片),但有时加载我的网站却需要 10-15 秒,浏览器甚至会直接卡住。
Before anyone gets the wrong idea, I’m not blaming Codeberg for this in any shape or form. In fact I’m very grateful, that the option exists in the first place. After all, they are a (relatively) small non-profit, who have to serve not just my silly little webpages, but sites for far more serious projects too. With this in mind, it’s no wonder they can’t always afford the computing power for me. However, as much as they have my sympathies, I was still stuck with this problem and had to figure out some solution. And said solution was joining something useful with something pleasant: Enter VPS-es.
在有人产生误解之前,我声明我绝不是在以任何形式责怪 Codeberg。事实上,我非常感激他们提供了这个选择。毕竟,他们是一个(相对)小型非营利组织,不仅要为我这些无足轻重的小网页提供服务,还要为更严肃的项目提供支持。考虑到这一点,他们无法总是为我提供足够的计算能力也就不足为奇了。然而,尽管我很同情他们,但我仍然面临这个问题,必须想出解决办法。而这个办法就是将实用与愉悦结合起来:VPS 登场了。
1.1 Picking my provider
1.1 选择服务商
A VPS is a managed virtual machine, that one may rent from cloud provider companies. The userbase is very wide, you can find people using them from all areas of life, from students and hobbyists, to very serious and large companies, who don’t want to bother with on-prem solutions. These days, if one happens to fall into the former category and only really needs a machine that has some minimal RAM and a reasonably fast few (perhaps even one) core CPU, they have a plethora of providers to pick from, who specialize in pushing down prices and lending you such VMs for literal peanuts.
VPS 是一种托管虚拟机,可以从云服务商处租用。其用户群非常广泛,涵盖了各行各业,从学生和爱好者,到不想折腾本地服务器的大型企业。如今,如果你属于前者,只需要一台拥有少量内存和一颗(甚至可能只有一颗)速度尚可的 CPU 的机器,那么有大量的服务商可供选择,他们专门通过压低价格,以极低的成本将此类虚拟机租给你。
2 German bureaucracy
2 德国官僚作风
As explained earlier, my choice fell on the VPS Pico G11s. At first the process was as one would expect: I put the VPS in my cart, entered my address and personal data, then clicked through the pages, until I noticed that there is a Netcup newsletter and if you sign up for it, you get a voucher for 5€ off. I figured “Hell yeah, that’s almost three months” and signed up. The voucher arrived almost instantly and I happily saw that after entering it, the price of the VPS dropped from 24€ to around 19€. Everything seemed fine, so I pressed on the big, friendly “Order” button… And was thrown back with an error.
如前所述,我选择了 VPS Pico G11s。起初,流程正如预期的那样:我将 VPS 加入购物车,输入地址和个人资料,然后点击页面,直到我注意到 Netcup 有一份时事通讯,注册即可获得 5 欧元的优惠券。我想“太棒了,这几乎是三个月的费用”,于是就注册了。优惠券几乎立即送达,我高兴地发现输入优惠券后,VPS 的价格从 24 欧元降到了 19 欧元左右。一切看起来都很顺利,于是我按下了那个大大的、友好的“订购”按钮……结果却弹回了一个错误。
Apparently the VPS I picked was too cheap for the voucher to be applicable for, so I begrudgingly removed it and proceeded with the full price. At the end of the day, 24€ is the cost of two fancy lunches, so I wasn’t going to throw everything away just because I couldn’t be even more of a cheapskate. Having corrected my deal and pressed “Order” again, I expected to be redirected to a payment portal. Instead, I was simply informed that an actual human being will verify that my order is legit and that I must wait until that happens.
显然,我选的这款 VPS 太便宜了,无法使用该优惠券,所以我只好不情愿地删除了优惠券,按原价继续购买。说到底,24 欧元也就两顿精致午餐的钱,我没必要因为不能再省点钱就放弃一切。修正订单并再次按下“订购”后,我本以为会被重定向到支付页面。结果,我只是被告知会有专人核实我的订单是否合法,我必须等待核实完成。
Considering this was very late in the afternoon (way past the usual European working hours), I sighed and resigned myself to wait until the next day or however long it’d take. In the meantime I received an email, which I found really interesting. It was written in a very serious and legalese way, with long paragraphs of dry text describing my rights and responsibilities, a…
考虑到当时已经是傍晚(远超欧洲通常的工作时间),我叹了口气,认命地等待第二天或更久。与此同时,我收到了一封邮件,我觉得非常有趣。邮件写得非常严肃且充满法律术语,用大段枯燥的文字描述了我的权利和义务,以及……