wget连接在同一服务器上超时

问题描述:

我遇到了一个非常奇怪的问题。

I've got a very strange problem.

服务器上有一项cron作业,每天运行脚本:

There's a cron job on the server to run a script daily:

wget -O /dev/null --timeout=300 --tries=1 "http://website.com/script"

自大约两周前以来一切正常,我开始收到错误:

It was all working well since about two weeks ago, I started receiving errors:

--2016-07-13 09:45:01--  http://website.com/script
Resolving website.com (website.com)... 11.22.33.44
Connecting to website.com (website.com)|11.22.33.44|:80... failed: Connection timed out.
Giving up.

这些是有关此问题的一些信息:

These are some information for this question:


  1. cron作业位于 http://website.com 托管的同一服务器上。

  2. 我可以访问脚本( http://website.com/script)可以从我桌面上的浏览器正确访问。

  3. 服务器为CentOS 7,安装了WHM和cPanel。

  1. The cron job is on the same server of http://website.com hosted.
  2. I can access the script (http://website.com/script) correctly from browser on my desktop.
  3. The server is CentOS 7, with WHM and cPanel installed.

有人知道这可能是什么问题吗?或我应该如何确定问题所在?

Anyone know what could be the issue? or how do I suppose to identify the issue?

谢谢

如果问题仍未解决。.
您可以尝试在调试模式下运行wget以查看是否获得更多信息。

If the issue still is unresolved.. You could try running wget in debug mode to see if you get some more info.

wget -dv -O /dev/null --timeout=300 --tries=1 "http://website.com/script" 

还请确认已解析的IP 11.22.33.44是否属于服务器NIC之一。

Also, confirm if the resolved IP "11.22.33.44" belongs to one of the servers NIC's.

ip as (显示IP地址)或

ifconfig -a

如果未列出IP,则可能是IP 11.22.33.44是公司防火墙的公开地址。并且FW正在将来自外部/互联网(浏览器所在)的端口80上的请求定向到该特定服务器。并且可以将Firewall / Nat / Proxy配置为不允许来自网络内部,到达防火墙的外部IP并重新进入的请求。

If the IP is not listed, It could be that the ip "11.22.33.44" is a public facing address of the company's firewall. And that the FW is directing requests on port 80 from the outside/internet (where you're browser is) to that specific server. And the Firewall/Nat/Proxy, could be configured to not allow requests coming from inside the network, reaching the external IP of the firewall and getting back in.

如果这在这种情况下,您可以尝试使用内部IP地址来更改自己的wget,例如:(仍然使用 -dv 进行调试,之后删除)

If this is the case, you could try changing you're wget using the internal ip address, something like: (still using -dv for debugging, remove after)

wget -dv -O /dev/null --timeout=300 --tries=1 --header="Host: website.com" http://127.0.0.1/script

注1:-header = Host:website.com 会告诉您Web服务器您想要访问的站点

Note1: the --header="Host: website.com" will tell you're webserver what site you wanna reach

注意2:也许您必须更改IP:127.0.0.1(本地主机地址)到服务器的NIC地址之一。

Note2: maybe you'll have to change the IP: 127.0.0.1 (localhost address) to one of the server's NIC addresses.