blocking ip addresses using .htaccess in a cloud environment

been having some trouble restrict­ing access to this site by ip address using .htac­cess.
the tra­di­tional method is to use a format like this:

order allow,deny
deny from 10.11.13.14
deny from 16.15.14.13
allow from all

this wouldn’t work for me at all. the only way i could make it have any effect was to comment out ‘allow from all’. this pro­duced a 403 error for every attemp­ted connect.
i con­tac­ted my hosting pro­vider (laugh­ing squid) as i couldn’t think of any­thing else to try.
after some troubleshoot­ing it turns out that sites hosted in the cloud (at least the rack­space cloud’s envir­on­ment) require a dif­fer­ent method to ban by ip in .htac­cess. more info can be found here.
so i added the fol­low­ing to my .htac­cess file:

SetEn­vIf X-Cluster-Client-Ip “^10\.11\.12\.13″ Deny­Ac­cess
Order Allow,Deny
Deny from env=DenyAccess
Allow from all

obvi­ously replace the ip with the one you’d like to block. if you want to ban mul­tiple ip addresses just repeat line one and alter it accordingly.

so thanks to laugh­ing squid’s support team…quick response as always.

Post to Twitter

0 Responses to “blocking ip addresses using .htaccess in a cloud environment”


Comments are currently closed.

Bear