Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a php script on my site that, when run, changes the 'Dog of the Day' on my home page. I have a cron job set up to run the script once a day, and everything works perfectly.

I've secured my 'scripts' directory with an .htaccess file, because if someone stumbles upon the php script, it'll be run, causing the 'Dog of the Day' to be updated.

ErrorDocument 404 /404.php

order deny,allow
deny from all
allow from 127.0.0.1

I changed the cron job to run every minute, but the .htaccess is blocking it, despite 127.0.0.1 being whitelisted. I changed 127.0.0.1 to my own ip, and I can access it, so it's not a problem with syntax.

I'm a graphics designer by trade, and a front-end coder at a push, so keep it simple please!

Thanks a lot!

share|improve this question

closed as off topic by MDMarra, Ward, mdpc, growse, Scott Pack May 18 '13 at 19:27

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 3 down vote accepted

Your script being run from cron is not accessing your own site on the same server via 127.0.0.1, but by its actual IP address.

For instance, you are probably doing something like:

curl http://www.example.com/scripts/update-dog-of-the-day.php

But www.example.com doesn't resolve to localhost, but to your public IP address.

To resolve the issue, whitelist your public IP address instead.

Allow from 203.0.113.17
share|improve this answer
    
Awesome. I'll try it when I get home... so what exactly is 203.0.113.17? When I look it up, it's an IP from China! –  Starkers Mar 12 '13 at 23:09
    
I really doubt that you found that IP address in China. It is a reserved address for use in documentation and should never be seen on the public Internet. This makes it useful for examples. See RFC 5737. –  Michael Hampton Mar 12 '13 at 23:13
    
So 203.0.113.17 is just an example? –  Starkers Mar 12 '13 at 23:29
    
Precisely. Just like www.example.com is an example. (It's defined in RFC 2606.) –  Michael Hampton Mar 12 '13 at 23:30
    
Right, I was wondering how you knew! –  Starkers Mar 12 '13 at 23:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.