I have the following code in my virtual host file:

     ServerAdmin something@site.com
     ServerName mysite.com
     DocumentRoot /var/www/mysite.com/public_html/
     ErrorLog /var/www/mysite.com/logs/error.log
     CustomLog /var/www/mysite.com/logs/access.log combined

<Directory /var/www/mysite.com>
  order deny,allow
  deny from all
  allow from

Then i restarted apache. But for some reason, everyone can still see the website. I want only users with IP address to be able to see my site.

What am I doing wrong?

  • How are you testing? What URL are you using? – David Schwartz Aug 1 '14 at 23:07
  • I tested by going to the actual url http://mysite[dot]com . I can't disclose the url right now. But when i tell my friends to go to it, they can see the site . I remember the code above worked before on another CentOS server. But it doesn't seem to be working on this ubuntu server. Am I missing modules for apache or something? – John Aug 1 '14 at 23:49
  • I don't really follow. In the DNS settings for mysite.com, i made an A record with the ip address, because that's the IP address of my ubuntu/apache server. Then I'm expecting anyone with an authorized IP address to be able to type mysite[dot]com into their browser and see the pages served from the /var/www/mysite.com/public_html folder. The only issue is that Apache isn't denying non- ip address users. Everyone is seeing the contents of /var/www/mysite.com/public_html . Can you tell me what I mis-understood about the set up? – John Aug 2 '14 at 0:05
  • 1
    You're 100% positive the URL contains /mysite.com/ and not a www or anything else in there? – David Schwartz Aug 2 '14 at 0:43
  • 1
    Please share your complete config, a <Location /> block with Allow from all could thwart this. – fuero Aug 2 '14 at 2:30

Possible answer:


Ensure you are loading mod_authz_host


Double check your DNS lookup for your "mysite.com" from your friend's computers - they could be connecting through a different interface to the service with the same DocumentRoot, or a page which looks the same as what you're trying to protect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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