2

分享一个快速从国外服务器下载文件到本地的方法: vps 中转,vps 先下载好,再从 vps...

 2 years ago
source link: https://hellodk.cn/post/193
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

需求是下载一个 arm64 架构、Android 10 的 gapps 包,但是我用移动家宽、用电信 4G、联通 4G、挂着 global proxy (通过移动家宽) 的情况下速度都很慢,只有十几二十 KiB/s,实在是不能忍。心想以前也用过 wget,为什么不直接在 vps 上下载呢?

image.png

0202 年了如果通过几十 KiB/s 速度下载,你愿意等待吗

方法就是首先通过 wget 在 vps 上下载好,然后再通过 winscp 等软件拉到本地 (以前用过 winscp 拉) 现在想想跨平台,那就直接通过 http 服务吧,nginx 多配置一个 server 块 就好了

一、通过 vps 下载源文件

# wget https://nchc.dl.sourceforge.net/project/opengapps/arm64/20200422/open_gapps-arm64-10.0-micro-20200422.zip

下面是当时的文本,我给拷贝下来了,均速也不是很好,才 1.69MiB/s

[root@hostname temp]# wget https://nchc.dl.sourceforge.net/project/opengapps/arm64/20200422/open_gapps-arm64-10.0-micro-20200422.zip
--2020-04-23 12:00:35--  https://nchc.dl.sourceforge.net/project/opengapps/arm64/20200422/open_gapps-arm64-10.0-micro-20200422.zip
Resolving nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)... 2001:e10:ffff:1f02::17, 140.110.96.69
Connecting to nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)|2001:e10:ffff:1f02::17|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 232768166 (222M) [application/octet-stream]
Saving to: ‘open_gapps-arm64-10.0-micro-20200422.zip’

100%[=================================================================================================================>] 232,768,166 2.00

2020-04-23 12:02:47 (1.69 MB/s) - ‘open_gapps-arm64-10.0-micro-20200422.zip’ saved [232768166/232768166]

二、配置个 http 服务,然后通过 http 服务下载该文件

/etc/nginx/vhost 下 new 一个 files.conf
vim cat /etc/nginx/vhost/files.conf

[root@hostname ~]# cat /etc/nginx/vhost/files.conf
server {
listen 45678;
server_name pt.hellodk.com;
root /temp/nginx-static-file/;
index index.html;
error_page 404 /404.html;
location = /40x.html {
error_page 500 502 503 504 /50x.html;
location = /50x.html {

然后执行 nginx -t 通过后执行 nginx -s reload

写一个 index.html 测试,放在 /temp/nginx-static-file 下,访问 http://pt.hellodk.com:45678/index.html ,如下图

image.png

说明 nginx 配置生效了

把我们的 open_gapps-arm64-10.0-micro-20200422.zip 文件放在 /temp/nginx-static-file 下,访问 http://pt.hellodk.com:45678/open_gapps-arm64-10.0-micro-20200422.zip 即可,

image.png

我是从 chrome 访问该 url 自动调用 Free Download Manager 的 (chrome 需要安装 fdm 的扩展 Free Download Manager)

image.png

image.png

速度真心美滋滋,一会就下载好了 hmmm 这里抛出个问题?为什么 global proxy 和直接下载差别这么大呢?后者数据是直接从 server 到 中转 server 最终到 client 的? 但是经过了两次下载

ps: 文章中的 端口 45678 是假的 [旺柴] 本文分享到这里,有疑问请留言


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK