Nginx – Cron Daemon Wget blocked

crondebian-wheezyhttp-status-code-403nginxwget

I've got nginx on Debian 7 without cpanel.

I am seting-up my Crontab like this:

*/45 * * * * wget "http://example.com/cron-url.php" >/dev/null 2>&1

The above cron is being blocked with 403 forbidden:

--2014-12-10 05:40:01--  http://example.com/cron-url.php
Connecting to xyz.xx.xx.xxx:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2014-12-10 05:40:01 ERROR 403: Forbidden.

After searching here and googling, I understand that my server is probably blocking wget. I had a look at my nginx configuration file and I think it should be due to this:

if ($http_user_agent ~* LWP::Simple|BBBike|wget) {
    return 403;
}

For cron command, I have to use the url to it and absolute link to script path doesn't work. Now, what do I do if I need to allow cron to work without getting blocked? I was thinking maybe I need to allow wget from my own server, but don't know how to do that with nginx. Can someone help me resolve this cron issue?

Best Answer

Either remove wget exclusion from the nginx configuration, or add something like this as an option to your wget command:

--user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101  Firefox/21.0" --referrer whatever.example.com
Related Topic