简体   繁体   English

Curl&Wget返回响应,浏览器超时

[英]Curl & Wget returning response, Browser times out

I am sending requests to a specific server on a cloud: 我正在将请求发送到云上的特定服务器:

wget --header="Host: example.com" http://x.x.x.x:80/
curl -i -H"Host: example.com" http://x.x.x.x:80/

And it returns exactly as expected (a simple static file). 并且它完全按预期返回(一个简单的静态文件)。 However, when I try and access it in a browser, the request times out. 但是,当我尝试在浏览器中访问它时,请求超时。 I can't imagine it would be a user agent header issue, but then again, I don't really know what else it would be. 我无法想象这将是一个用户代理标头问题,但是话又说回来,我真的不知道还会发生什么。

It isn't going to a load balancer or anything, should be going directly to the site. 它不会去负载均衡器或其他任何东西,应该直接去站点。 Any ideas on why this might be happening? 为什么会发生这种情况的任何想法? I have my hosts file set to go to that specific IP address. 我将主机文件设置为转到该特定IP地址。

Thanks 谢谢

It looks like you're specifying an IP address in wget/curl but a hostname in your browser. 您似乎在wget / curl中指定了IP地址,但在浏览器中指定了主机名。 This creates additional variables in the test and we can't troubleshoot the results. 这会在测试中创建其他变量,因此我们无法对结果进行故障排除。 (You need to better control the test.) (您需要更好地控制测试。)

Try replicating your browser logic on the command line: 尝试在命令行上复制浏览器逻辑:

wget http://example.com/

This performs the same test as you want in your browser with wget . 这将使用wget在浏览器中执行所需的测试。

If it works , you have a configuration issue with your browser (or perhaps any proxy settings inherited from your OS). 如果可行 ,则说明您的浏览器存在配置问题(或者可能是从操作系统继承的任何代理设置)。

If it does not work , you likely have an issue with your hosts file. 如果不起作用 ,则您的主机文件可能存在问题。

You can also try the test in reverse; 您也可以反向进行测试; find some browser add-on that lets you specify/alter arbitrary headers or that explicitly lets you set the hostname separately from the URL and then go to http://xxxx:80/ as you did with wget/curl. 找到一些浏览器附加组件,使您可以指定/更改任意标题,或者可以明确地使您独立于URL设置主机名,然后像使用wget / curl一样转到http://xxxx:80/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM