即使在 Cloudflare Rules 中进行了正确的配置设置,也会出现 301 重定向错误

Getting the 301 redirect error even with the proper config setup in Cloudflare Rules

我正在尝试使用 Cloudflare 作为我在 Vercel 上托管的网站的 DNS。我的 DNS 配置设置为使用 Proxied 设置打开。不过,Vercel 表示反对。但是他们有办法在 doc 中允许 Proxied DNS 配置。我做了同样的事情,并使用如下所示的设置创建了一个页面规则。

现在,预期的错误应该是 404 Not Found,但我收到了 301 Permanent Redirect 错误。

HTTP/1.1 301 Moved Permanently
Date: Sun, 05 Sep 2021 08:38:30 GMT
Connection: keep-alive
Cache-Control: max-age=3600
Expires: Sun, 05 Sep 2021 09:38:30 GMT
Location: https://dispatchbot.ml/.well-known/acme-challenge
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=wImD0Hy4nEZEgaw3eCBVGSVyscQ8zEezbEjTjSJPIOSL%2BnsDFGnrbsyJkgP3LqweeZ0uC85E6kK%2FO4nPFA23%2BZaF5jgCZJOnawGwIotLAZ7nySmGHfHopr1qrut%2FaFDePg%3D%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 689e244b8fb00efc-BOM
alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400, h3=":443"; ma=86400

注意:我正在使用 Always use HTTPS 设置,SSL/TLS Encryption 设置设置为 Full (Strict)

问题可能与您的配置有关。根据您列出的 Vercel 文档页面

The domain must allow HTTP requests (without HTTPS) to the path /.well-known/*.

但是你说你启用了 Always use HTTPS,这会将 HTTP 请求重定向到 HTTPS(因此也会在 /.well-known/ 路径上强制使用 HTTPS。看来您还启用了 HSTS,它将在浏览器中强制执行 HTTPS。

一个潜在的解决方案可能是删除 HSTS(但这可能需要一些时间才能根据所使用的策略反映在浏览器中)并通过页面规则配置始终使用 HTTPS,而不是将其从 /.well-known/ 中排除路径。