I have to deal with all kinds of issues at work and today I learned about how Mosso (a cloud hosting company) doesn't play nice with request ip addresses. Basically the issue is that the requesting ip coming into a server is the ip of their load balancing server instead of the visitor's. This means limiting access on an ip level through .htaccess becomes problematic. The answer is that they provide an environment variable called X-Cluster-Client-Ip which has the visitor's ip. Now this can be checked and access can be restricted using this. I have included an example .htaccess script below.
order deny,allow
deny from all
allow from env=allowclient
Now, i would assume other cloud hosting companies would have something similar. Anyway just caused a few hours of head ache, especially when the owner calls you and says fix it.
04/29/2009 - 07:57
I'm having to do the same thing, did you have any problem with the display of images?
I'm wondering if their media accelerator servers use a different variable as I have used both the classic "deny from " as well as the method you mention above, and text content works, but all images give me a 403.
Not really sure how to progess!
04/29/2009 - 09:07
Yeah I had the same issue. I had to add the following to the end of my .htaccess file.
order deny,allow
allow from env=allowclient
</FilesMatch>
The main thing is here is to make sure that the
FilesMatchregular expression has all the correct file extensions.04/29/2009 - 09:42
Works perfect (except it should be "jpe?g")!
I will point the engineers at this link, thanks.
12/15/2009 - 16:02
Thanks! This fixes the images issue!
09/01/2010 - 12:39
thank you for sharing, this saved my some headache!
07/19/2011 - 16:17
Hi,
This is good information - I'm curious if you know how do do a block of an IP range. e.g. block a class C or B.
I tried similar syntax to what you had, but without success:
SetEnvIf X-Cluster-Client-Ip 182.236. blockclient
Order Allow,Deny
Deny from env=blockclient
Allow from all
Add Comment
[language] [/language]
Examples:
[javascript] [/javascript]
[actionscript] [/actionscript]
[csharp] [/csharp]
See here for supported languages.
Javascript must be enabled to submit anonymous comments - or you can login.