如何使用代理服务器、varnish 提高 HLS 视频速度?或者另一种方式
我有 2 台服务器,A 和 A。 B.
A - Canada - VPS
B - Germany - DC
C - Brazil - User
B 到 C - 有很多延迟,连接不良。有时500kbps。
A 到 C - 在大多数计算机上都很好。 2Gbps 全速 vps。
B 到 A 到 C - 在大多数计算机上都非常好。 600mbps~900mbps。
我按需使用 HLS,我想知道一种方法,使服务器 B 的连接通过服务器 A 并以专业的方式到达客户端。提取整个连接。
我尝试了 nginx 代理,但我不知道我是否走在正确的道路上。 我尝试了 Varnish,但我不知道如何配置它,也不知道这是否是最好的方法 我尝试将远程磁盘B挂载到VPS(服务器A)上
I have 2 servers, A & B.
A - Canada - VPS
B - Germany - DC
C - Brazil - User
B to C - There is a lot of lag, bad connection. 500kbps some times.
A to C - Very good on most computers. 2gbps all speed vps.
B to A to C - Very good on most computers. 600mbps~900mbps.
I use HLS on demand, I would like to know a way to make the connection from server B go through server A and go to the client in a professional way. Extracting the whole of the connection.
I tried nginx proxy but I don't know if I'm on the right path.
I tried Varnish but I didn't know how to configure it and I don't know if it's the best way
I tried to make the remote disk B be mounted on the VPS (Server A)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你构建的是一个小型的私有CDN。 Varnish 是构建 CDN 的绝佳工具。
起源与加拿大 CDN POP
我不会远程安装磁盘,我会建立一个服务器作为您的源服务器。该服务器拥有通过 Web 服务器从磁盘提供的所有 HLS 数据。这可能是 Apache 或 Nginx。
假设此服务器安装在加拿大,并具有假设的主机名
ca.example.com
。在此服务器上,您将在端口
8080
上运行 Web 服务器,并在端口80
上运行 Varnish。您还可以安装 Hitch 作为 TLS 代理并处理端口443
以进行 TLS 终止。该服务器将充当来源,同时也充当加拿大存在点。最重要的是,当其他 POP 连接重新验证内容时,Varnish 还将充当“原始防护罩”。
德国 POP
德国的服务器也可以充当 CDN POP,并在端口
80
上安装 Varnish,并在443
上安装 Hitch。想象一下该服务器是
de.example.com
。该 Varnish 服务器将指向 ca.example.com 作为其后端,基本上从加拿大的 Varnish 服务器获取内容,并在德国缓存它。
路由流量
为了减少延迟,您可以使用地理位置感知来查找最近的 POP。您的 DNS 服务器可以处理这个问题。
假设,您可以创建多个
www.example.com
DNS 记录,这些记录使用地理位置路由规则来解析到正确的 IP。例如,如果检测到用户所在的洲,您可以为
www.example.com
创建一条指向ca.example.com
的CNAME
记录是北美。您可以创建针对南美洲的相同规则。
位于欧洲的用户将拥有指向德国
de.example.com
的www.example.com
的CNAME
记录。然后就是为来自其他大陆的用户定义后备方案的问题。
AWS Route 53 在这方面非常擅长。它是支持地理定位的 Amazon Web Service 的 DNS 服务器。
相关设置及安装指南
What your building is a small private CDN. Varnish is a great tool to build out a CDN.
Origin & Canadian CDN POP
I would stay away from mounting disks remotely and I would establish a single server as your origin server. This server has all the HLS data that it serves from disk via a web server. This could be Apache or Nginx.
Let's assume this server is installed in Canada and has the hypothetical hostname
ca.example.com
.On this server you would run the web server on port
8080
and Varnish on port80
. You could also install Hitch as the TLS proxy and process port443
for TLS termination.This server would act as the origin but also as the Canadian Point Of Presence. On top of that the Varnish would also serve as an "origin shield" when other POPs connect to revalidate content.
German POP
The server in Germany could also serve as a CDN POP and have Varnish installed on port
80
and Hitch on443
.Imagine this server being
de.example.com
.This Varnish server would point to
ca.example.com
as its backend, basically fetching the content from the Varnish server in Canada and also caching it in Germany.Routing traffic
In order to reduce latency, you can use geolocation awareness to find the closest POP. Your DNS server could take care of this.
Hypothetically, you could create multiple
www.example.com
DNS records that use geolocation routing rules to resolve to the right IP.You could for example create a
CNAME
record forwww.example.com
that points toca.example.com
if the detected continent for the user is North America.You could create the same rule that is targeted at South America.
Users located in Europe would have a
CNAME
record forwww.example.com
that points tode.example.com
in Germany.And then it's a matter of defining a fallback for users coming out of other continents.
AWS Route 53 is pretty good at this. It's Amazon Web Service's DNS server that support geolocation.
Relevant setup & install guides