I have a monit script that checks that nginx is up and running. One thing it does is checks for a file 'ping.txt'. I can view it in the browser, but what would cause the script to get a 301 redirect response back?
monit script snippet:
if failed port 80 protocol http and request '/ping.txt'
Here's what's in the nginx log:
127.0.0.1 - - [29/Feb/2012:20:59:58 +0000] "GET /ping.txt HTTP/1.1" 301 185 "-" "monit/5.2.5"
Are you actually able to browse to ping.txt on the localhost? Maybe you need to try the LAN IP.
You can use a shell browser such as lynx or links2 to test. From your comment I see you may have configured it as a virtualhost. You mayneede to access the webpage using the hostname or full url, i.e. http://www.example.org/ping.txt.
In your example you try to access 127.0.0.1 hence your webserver returns a 301.
To change the host do something like:
Or leave out the address.
I know this is old but I had the same problem and got to this question through googling "monit 301" the problem in my case after quite a lot of hair pulling was that "monit was not setting the hostname header when checking my server, thus it did not get directed to the correct vhost. You can add the hostname to the check with the hostheader directive eg: