Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Responds 503 with absent of User-Agent header #62

Open
5long opened this issue Jan 5, 2024 · 2 comments
Open

Responds 503 with absent of User-Agent header #62

5long opened this issue Jan 5, 2024 · 2 comments
Assignees
Labels

Comments

@5long
Copy link

5long commented Jan 5, 2024

重现步骤

curl -v -A "" https://mirrors.cqu.edu.cn/ >/dev/null

期望结果

返回 200 响应

实际行为

返回 503

细节

发现这个 issue 的原因是 Arch Linux 的 pyalpm 库默认不会设置 User-Agent, 设置的办法比较隐晦, 又缺少文档, 一时没找到. 然后我自己又是 CQU 镜像的用户. 就撞上了

按照 HTTP 标准, 客户端的请求 SHOULD 带有 User-Agent header. 但如果没有, 服务器端最好也不要返回 503, 会造成用户的困惑 & 在服务器端制造不必要的报错. 返回 400 可能比较合适(虽然用户还是会困惑, 但这毕竟是客户端的行为不太标准)

尴尬的是, 在本地跑了从头建立了一个 nuxt@2.16.0 的项目, 并没有复现这个问题. 暂时没有再查下去 _(:з」∠)_

@weearc
Copy link
Collaborator

weearc commented Jan 7, 2024

发现这个 issue 的原因是 Arch Linux 的 pyalpm 库默认不会设置 User-Agent

由于安全问题默认空 UA 是被禁止访问的。其他使用 libalpm 的前端比如 pacman 会给出合适的包管理器 UA 。如果使用它的 python bindings 也务必带上 libalpm 的 UA 字符串。或参照 pamac 包裹 pacman 命令。

按照 HTTP 标准, 客户端的请求 应该带有 User-Agent header. 但如果没有, 服务器端最好也不要返回 503, 会造成用户的困惑 & 在服务器端制造不必要的报错。

这个规范首先要求客户端需要遵守。由于镜像滥用,给出 4XX http code 会导致滥用者不会主动断开连接,造成 nginx 连接池被耗尽,将影响正常用户的使用。因此非法 UA 或滥用行为我们是直接给出 5XX 错误码目前。详细情况仍需继续讨论。

尴尬的是, 在本地跑了从头建立了一个 nuxt@2.16.0 的项目, 并没有复现这个问题.

因为只请求了三个接口。该接口开发状态下暂无限制。

@weearc
Copy link
Collaborator

weearc commented Jan 7, 2024

CC @Hagb @Tiger3018
FYI @cyyself

@weearc weearc pinned this issue Jan 7, 2024
@weearc weearc self-assigned this Jan 7, 2024
@weearc weearc added the network label Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants