I had trouble running a cron script using the following command after switching server for one of our websites.

The website was hosted on a shared hosting at hostgator and it was working fine for long time. But after switching server to VPS, I started to get 403 errors whenever the cron script runs. After some research, I found out that mod_security is the one that is causing the trouble and there are three things you can do to solve the problem.

  1. Disable mod_security via .htaccess or uninstall it totally from your server
  2. Convert your script to curl
  3. White list your domain in mod_security configuration file

I think the best solution in terms of security is probably converting your script into curl but I chose option #3.

Here is what you need to add to white list your domain:

You can add the line anywhere in mod_security’s configuration file. I added mine simply at the top.

Tags: , , , , ,