我希望使用monit来监视我的网站。我希望它把它作为一个外部用户对待它,所以正在测试的网址,但它似乎不遵循重定向。内容检查正在重定向的html上执行。
#request works:
if failed url http://www.sharelatex.com/blog/posts/future.html content == "301"
#request fails
if failed url http://www.sharelatex.com/blog/posts/future.html content == "actual content"找出如何让网址检查跟随30X将是很好的。
发布于 2012-03-20 15:02:31
尽管我在monit手册页中没有看到一个选项使它遵循重定向,但我认为通过显式测试重定向的元素。首先测试重定向头,然后测试目标页面的内容,从而实现相同的目标。
(这是响应,包括从请求重定向到sharelatex )
HTTP/1.1 301 Moved Permanently <---- response code here
Server: nginx/0.7.65
Date: Tue, 20 Mar 2012 22:04:48 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Location: https://www.sharelatex.com/blog/posts/future.html <---- target location here我会用下面这样的东西;
check host www.sharelatex.com with address www.sharelatex.com
IF FAILED URL http://www.sharelatex.com/blog/posts/future.html content == "301 Moved Permanently"
then alert
IF FAILED URL http://www.sharelatex.com/blog/posts/future.html content == "Location: https://www.sharelatex.com/blog/posts/future.html"
then alert
IF FAILED URL https://www.sharelatex.com/blog/posts/future.html content == "ShareLaTeX"
then alert所以打破它..。这两行检查HTTP://页面重定向是否正确,并检查它是否为重定向提供了正确的目标。
check host www.sharelatex.com with address www.sharelatex.com
IF FAILED URL http://www.sharelatex.com/blog/posts/future.html content == "301 Moved Permanently" then alert
IF FAILED URL http://www.sharelatex.com/blog/posts/future.html content == "Location: https://www.sharelatex.com/blog/posts/future.html" then alert 然后测试你是否被重定向到正确的地方,并得到一些内容.
然后,下面的行,有效地显式地执行重定向,并在https://www.sharelatex.com/blog/posts/future.html上测试HTTPS页面的内容
IF FAILED URL https://www.sharelatex.com/blog/posts/future.html content == "ShareLaTeX" then alert 我猜第一批命令每页会产生一堆(2倍)的请求,所以可能值得将它们组合在一起.
https://serverfault.com/questions/371576
复制相似问题