301当monit检查nginx上的文件时的响应

我有一个监控nginx启动并运行的监控脚本。 有一件事是检查一个文件“ping.txt”。 我可以在浏览器中查看它,但是会导致脚本获得301redirect响应?

monit脚本片段:

if failed port 80 protocol http and request '/ping.txt' 

以下是nginx日志中的内容:

 127.0.0.1 - - [29/Feb/2012:20:59:58 +0000] "GET /ping.txt HTTP/1.1" 301 185 "-" "monit/5.2.5" 

你真的能够浏览到本地主机ping.txt? 也许你需要尝试局域网IP。

你可以使用shell之类的浏览器如lynx或者links2来testing。 从你的评论我看你可能已经configuration为虚拟主机。 您可能会使用主机名或完整url访问网页,即http://www.example.org/ping.txt

在你的例子中,你尝试访问127.0.0.1,因此你的web服务器返回一个301。

要更改主机,请执行以下操作:

 check host host.example.com with address 192.0.43.10 if failed port 80 protocol http and request '/ping.txt' 

或者留下地址。

我知道这是旧的,但我也有同样的问题,并通过谷歌search“monit 301”这个问题在我的情况下拉了很多头发后,“监测检查我的服务器时,没有设置主机名标题它没有被引导到正确的虚拟主机上,你可以使用hostheader指令将主机名添加到检查中,例如:

 check host www.mysite.co.uk with address wwwmysite.co.uk if failed port 443 protocol https and request / hostheader www.mysite.co.uk and status = 200 then alert