从CloudFlare提供静态文件

发布于 2025-02-10 20:33:29 字数 751 浏览 3 评论 0 原文

体系结构说明

我有一个Django应用程序托管在Azure应用程序服务器上,并通过Cloudflare的DNS托管。

该应用程序效果很好,并且使用 whitenoise 我能够服务存储的静态文件在App Service(10 GB)提供的Azure App服务存储容器中。事实是,存储服务仅Web应用程序使用的文件(在构建过程中上传的文件,没有手动添加其他文件的选项),并且仅限于100GB/月出口带宽。

我想尝试使用 cloudflare的R2 存储,因为它具有无限的带宽,并且允许,并且允许,并且允许您上传任何类型的文件。我将主要使用图像。


问题

How can static files be serve from Cloudflare's R2 on a Django app?
编辑:
I have successfully connected to my Cloudflare's R2 bucket using [Boto3][1] but still can't link to the Django app on Azure.

Architecture Description

I have a Django app hosted on an Azure App Service container and proxy through Cloudflare's DNS.

The app works great, and using WhiteNoise I am able to serve static files stored in the Azure App Service storage container that is provided with the App Service (10 GB). Thing is, the storage serves files used by the Web App only (files uploaded during build, there's no option to manually add other files), and it is limited to 100GB/month of egress bandwidth.

I would like to try and use Cloudflare's R2 storage, as it has unlimited bandwidth, and allows you to upload any kind of files. I'll mainly be using images.


Question

How can static files be serve from Cloudflare's R2 on a Django app?


EDIT:

I have successfully connected to my Cloudflare's R2 bucket using [Boto3][1] but still can't link to the Django app on Azure.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

征棹 2025-02-17 20:33:29

我不知道从成本/延迟的角度来看,R2将如何充当CDN,但是只要您保持在自由限制之内,它可能大部分都很好(TTFB延迟将是最大的问题,例如任何对象存储) 。

我们正在努力使将缓存放在R2面前成为可能,从而有助于性能&一旦可用的费用。

不幸的是,我认为这将是一种糟糕的媒介来调试您的问题,因为这还不清楚。也许在

由于这听起来像是很棘手的工作,如果您有一个工作示例,我们很乐意在

I don't know how well R2 will function as a CDN from a cost/latency perspective, but as long as you stay within the free limits it's probably mostly fine (TTFB latency is going to be the biggest issue as with any object store).

We are working on making it possible to put Cache in front of R2 so that will help on the performance & cost front once that becomes available.

Unfortunately, I think SO is going to be a poor medium to debug your issue as it's unclear. Perhaps get realtime help on the R2 discord and then come back here to post the answer once you figure out your issue?

Since this sounds like tricky work, if you have a working example, we're happy to host it on https://developers.cloudflare.com/r2/examples/.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文