# 登录后出现 401 未授权错误

**URL:** https://meta.discourse.org/t/401-unauthorized-error-after-login/316489
**Category:** Self-hosting
**Created:** [2024年七月16日 07:39 UTC](https://meta.discourse.org/t/401-unauthorized-error-after-login/316489 "2024-07-16T07:39:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Anjali\_Kumari](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/anjali_kumari/32/431915_2.png) [@Anjali\_Kumari](https://meta.discourse.org/u/Anjali_Kumari)
#### Post date: [2024年七月16日 07:39 UTC](https://meta.discourse.org/t/401-unauthorized-error-after-login/316489/1 "2024-07-16T07:39:24Z")

</div>

### **描述：**

在尝试访问 UI 时，我遇到了持续的 401 未授权错误。此错误发生在用户登录大约 20-30 分钟后。此外，在会话超时后，重新登录似乎需要 5-10 分钟的延迟。

**重现步骤：**

- 登录应用程序。
- 在不活动 20-30 分钟后访问 UI。
- 观察到 401 未授权错误。

**预期行为：**  
用户应保持身份验证状态，并且能够访问 UI，而不会遇到 401 错误。

**实际行为：**  
20-30 分钟后，应用程序会为请求的端点返回 401 未授权错误。

**附加信息：**

我在 NGINX 配置中实现了 `auth_digest_timeout`，但问题仍然存在。  
使用 curl 进行身份验证测试，最初成功，但在超时后最终返回 401 错误。

环境：  
NGINX 版本：1.25.4

**curl -v --digest -u admin:admin [http://192.168.10.148:20001/stream-viewer?stream](http://192.168.10.148:20001/stream-viewer?stream)**

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/d/c/2dcb3f09e23bad1151dc764a889bd11058926be4.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/5/5/c556cc044c08e79ea7ece21dffa0a893d226915d.png)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2024年七月16日 12:28 UTC](https://meta.discourse.org/t/401-unauthorized-error-after-login/316489/2 "2024-07-16T12:28:28Z")

</div>

这是标准安装吗？

这看起来像是 Nginx 错误。Nginx 不会在 Discourse 中进行身份验证。

您是否正在运行反向代理？Cloudflare？

我相当确定是 Discourse 以外的其他东西导致了此消息。
