Jira - REST API 在一个 VPS 上返回 HTML,但在另一个 VPS 上返回 JSON

Jira - REST API 在一个 VPS 上返回 HTML,但在另一个 VPS 上返回 JSON

我遇到了一个非常奇怪的问题,我无法解决。基本上,我有 2 台 VPS 机器,我通过 RDP 连接,因为它们都是 Windows Server 机器。我在两台机器上都安装了 cURL。一台运行 Windows Server 2016,我们将其称为服务器 A。另一台运行 Windows Server 2022,我们将其称为服务器 B。

如果我curl https://jira.mysite.com:2053/rest/api/2/serverInfo在服务器 A 上运行,我会得到一个有效的 JSON 响应,它是

{"baseUrl":"https://jira.mysite.com:2053","version":"8.22.2","versionNumbers":[8,22,2],"deploymentType":"Server","buildNumber":822002,"buil
dDate":"2022-04-20T00:00:00.000+1000","databaseBuildNumber":822002,"scmInfo":"266c8f51e3b1a891285d611f42f1d6c4389222af","serverTitle":"MY SERVER"
}

但是,如果我curl https://jira.mysite.com:2053/rest/api/2/serverInfo在服务器 B 上运行,我会得到 HTML

<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Just a moment...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="robots" content="noindex,nofollow">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="/cdn-cgi/styles/challenges.css" rel="stylesheet">


</head>
<body class="no-js">
...etc

发生了什么事。为什么我没有在服务器 B 上取回 JSON?这完全没有道理。

我唯一的猜测是 DNS 可能仍在传播,并且服务器 B 正在从旧 IP 地址提取数据,但自从我更新 DNS 以来已经过去了 4 个小时,所以我怀疑这不是问题所在。

任何建议都值得感激。谢谢。

答案1

我找到了问题所在。看来 Cloudflare 在发送 JSON 之前进行了干预,这就是为什么服务器 B 会将该 HTML 作为响应。Cloudflare 会发出检查,然后在检查通过后进行重定向。

如何修复

https://stackoverflow.com/questions/18500088/curl-load-a-site-with-cloudflare-protection https://community.cloudflare.com/t/how-to-whitelist-ips-through-cloudflare/417224

相关内容