# Avatar Proxy 和 CDN 热链保护

**URL:** https://meta.discourse.org/t/avatar-proxy-and-cdn-hot-link-protection/350525
**Category:** Support
**Created:** [2025 年2 月 4 日 22:18 UTC](https://meta.discourse.org/t/avatar-proxy-and-cdn-hot-link-protection/350525 "2025-02-04T22:18:57Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![LotusJeff](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lotusjeff/32/477888_2.png) [@LotusJeff](https://meta.discourse.org/u/LotusJeff)
#### Post date: [2025 年2 月 5 日 14:57 UTC](https://meta.discourse.org/t/avatar-proxy-and-cdn-hot-link-protection/350525/5 "2025-02-05T14:57:06Z")

</div>

> [@michaeld](#):
>
> 您能详细说明一下这是如何设置的吗？

我讨厌含糊不清的问题。你问“这个”的时候在想什么？

这是我当前的设置：

### Discourse 设置：

- 标准单容器安装
- 设置为子域名： forums.domain.tld
- 标准 S3 设置用于上传
- 上传文件保存在 S3 上

### S3 设置：

- Digital Ocean S3 存储桶
- 存储桶已开启外部访问
- 没有其他安全层或权限

### CDN 设置：

- bunny CDN
- 允许的引用者设置： domain.tld 和 \*.domain.tld
- 导致头像访问被禁止的开关是“阻止直接 URL 文件访问”。

开启后，所有头像都收到 403 错误。关闭后，头像可以正常显示。

非头像图片：

- Discourse 中的 URL： `https://cdn.domain.tld/optimized/3X/3/1/filename_#_size.jpeg`

头像图片：

- Discourse 中的 URL： `https://forums.domain.tld/user_avatar/forums.domain.tld/mazzini/48/776_2.png`

之前的一篇帖子 [头像如何存储和访问？](https://meta.discourse.org/t/how-are-avatars-stored-and-accessed/53065/1) 表明 Discourse 使用代理来处理头像。因此，头像的 URL 结构不是标准的图片 URL 结构。

在我的系统中，头像可以通过 S3 或 CDN 访问。这表明在某个地方/以某种方式，头像 URL 被转换为 CDN URL。

当这种情况发生时，CDN 会将该 URL 视为直接访问链接并以 403 错误阻止访问。

希望我回答了“这个”问题？

---

_[View the full topic](https://meta.discourse.org/t/avatar-proxy-and-cdn-hot-link-protection/350525)._
