注意:这篇文章上次更新于1478天前,文章内容可能已经过时。
This article was last updated1478 days ago, the content may be outdated.
摸鱼时光发现了一篇折腾 VPS 的博客,上面写着用 nginx 反代 GitHub,可以用于 GitHub 的下载加速,并且说理论上可以做任何网站的镜像。于是我也简单操作了一下。
During my idle time I found a blog post about tinkering with VPS. It described using nginx to reverse-proxy GitHub to speed up downloads from GitHub, and claimed that in theory you could mirror any website. So I went ahead and gave it a simple try.
操作步骤
-
环境安装
用 nginx 反向代理,自然需要安装 nginx 了,我这里使用的宝塔面板一键安装的 LNMP 环境。
-
准备一个域名并且解析到服务器上。
-
新建一个网站。

-
部署 SSL 证书,宝塔面板一键申请即可。
-
添加反向代理。


完成后,就可以通过域名访问 GitHub 了。

Steps
-
Install the environment
For nginx reverse proxying, you naturally need nginx installed. I used the one-click LNMP environment provided by the BaoTa panel.
-
Prepare a domain name and resolve it to your server.
-
Create a new website.

-
Deploy an SSL certificate — the BaoTa panel can apply for one with a single click.
-
Add the reverse proxy.


Once done, you can access GitHub through your domain name.

缺陷
但是这种方还是有很多缺点,比如说不支持 git clone 命令,只能通过点击页面上的 Download ZIP 来下载代码。
其实在这篇博客里也提供了反向代理的配置文件,并且这种方式是支持 git clone 的,但是不支持页面上的搜索功能,可能是少配置了什么。
所以在搜索和 git clone 之间我选择了搜索,其实我觉得是可以兼得的,等我研究研究再说。
除此之外像是图片等资源也是无法正常显示的,因为它来自别的地方。
登录账户也别想了,这只是用来下载的。
Drawbacks
But this approach still has quite a few shortcomings. For example, it doesn’t support git clone; you can only download the code by clicking “Download ZIP” on the page.
Actually, this blog post also provides a reverse-proxy config file, and that approach does support git clone, but the search feature on the page doesn’t work — maybe some configuration is missing.
So between search and git clone I chose search. Actually I think the two can coexist; let me look into it later.
Besides that, resources like images also fail to display properly, because they come from elsewhere.
Forget about logging in too — this is only meant for downloading.
使用方法
如果你看到了 https://github.com/Hello/Cuffs 这样的链接,但是你打不开。那么你可以尝试把 github.com 换成 github.dijk.eu.org 。在新的页面点击下载按钮进行代码下载。
除此之外,我还反代了 Google 搜索,大家可以使用 https://google.cuffs.cf 访问谷歌。
youtube 和 谷歌学术的反代尝试都失败了,看了一些博客感觉很复杂,放弃了。
Usage
If you see a link like https://github.com/Hello/Cuffs but can’t open it, you can try replacing github.com with github.dijk.eu.org. On the new page, click the download button to download the code.
Besides that, I also reverse-proxied Google Search — you can use https://google.cuffs.cf to access Google.
My attempts at proxying YouTube and Google Scholar both failed. After reading some blogs it seemed quite complicated, so I gave up.
Summary
Just documenting the reverse-proxy process.
In short, it proxies two addresses:
The nginx config file is as follows:
1 | server { |
1 | server { |


