Hello I have been trying to restrict access to a website to deny all and only let in a certain IP and certain subnets. I have tried adding to the options tab some require directives, but can't seem to get it to work. I was ok with the old method of deny all, allow IP, but times have changed. Any help appreciated. The below does not work for me in the options tab under Apache directives <Directory "/var/www/clients/client1/web4/web"> Require all denied Require ip 192.168.2.0/24 Require ip 173.176.xxx.xxx </Directory>
Try to add the same stanza for the symlinked path too: <Directory "/var/www/yourdomain.tld/web"> .....
So this works for the that single ip but not for subnet?? <Directory "/var/www/clients/client1/web4/web"> Require all denied Require ip 192.168.2.0/24 Require ip 173.176.131.191 </Directory> <Directory "/var/www/staging2.domain.com/web"> Require all denied Require ip 192.168.2.0/24 Require ip 173.176.131.191 </Directory>
192.168.2.0/255.255.255.0 gives same result, does not allow it. Oddly enough if i just put one ip from subnet it does not work either?? <Directory "/var/www/clients/client1/web4/web"> Require all denied Require ip 192.168.2.75 Require ip 173.176.131.191 </Directory> <Directory "/var/www/staging2.domain.com/web"> Require all denied Require ip 192.168.2.75 Require ip 173.176.131.191 </Directory>
I forgot i was internal but the server was external, i should have been putting my router public IP... stupid me, sorry to have wasted your time.