Get Paid to Participate     Twitter     Facebook     Google+
Hosting Discussion
 

Hosting Discussion > Web Hosting Forums > Essential Software & Control Panels > How to block users from accessing your site based on their IP address
forgot password?


Reply


Old
  Post #1 (permalink)   02-11-2007, 06:06 PM
HD Newbie
 
Join Date: Dec 2006
Posts: 15

Status: laarni080 is offline
Blocking users by IP address is pretty simple with .htaccess.
So here it is the example:

[CENTER]Order allow, deny
Deny from 192.168.0.10
Deny from 212.155.
Deny from 1.2.3.4 5.6.7.8 127.0.0.1
Allow from all
[/CENTER]

Let?s take a look at the code line by line:
The first line ?Order allow, deny? tells the web server the ?Order? in which the Allow and Deny directive will be evaluated. It simply says: Give access to all hosts that are not present in the Deny from list and are present in the Allow from list. With allow, deny order Allow list is looked up first and then the web server checks the deny from list. So as we have allow from all ? all access is allowed. Then the allowed access is filtered based on the Deny lists. With allow,deny access is disabled by default.

If we change the order to ?deny, allow? then all access is enabled by default and only users in the deny lists are blocked. However as the deny is being processed first allow directives will override any maching settings set in deny directives.

The default Apache order is deny,allow. So you can skip the first line in your .htaccess file if you do not need to change the order in which the Deny and Allow rules are being evaluated by the web server.

So to keep the .htaccess simple you can just use:

[CENTER]Deny from 192.168.0.10
Deny from 212.155.[/CENTER]


Basically you can use such rules in your .htaccess file to block a particular user, or a network from accessing your site.
You can put several IP address in a Deny or Allow rule. For example:

[CENTER]Deny from 1.2.3.4 5.6.7.9[/CENTER]

The IP addresses must be separated by a space or tab.

You can put entire networks as

[CENTER]
Deny from 212.155.[/CENTER]


This will block all users which IP addresses start with 212.155

Or to block all access to your site:
[CENTER]
Deny from all[/CENTER]


And then add another line to enable access only for yourself:

Allow from 1.2.3.4
Where ?1.2.3.4? should be replaced with your computer IP address.
 
 
 


Old
  Post #2 (permalink)   06-06-2007, 05:37 PM
HD Newbie
 
Join Date: Feb 2005
Posts: 16

Status: imported_Keith is offline
I've found that you have to be careful due to AOL in most cases. AOL can be a PITA at times with firewalls.
__________________
Keith
 
 
 


Old
  Post #3 (permalink)   06-21-2007, 04:47 AM
HD Amateur
 
Join Date: Oct 2006
Posts: 52

Status: aima123 is offline
Thanks for your detailed information laarni, it would really help.
 
 
 


Old
  Post #4 (permalink)   09-14-2008, 02:04 PM
HD Newbie
 
Join Date: Sep 2008
Posts: 27

Status: blackmetal is offline
thanks for thsi information but i think this method is good for plesk and directadmin control panels...
 
 
 


Old
  Post #5 (permalink)   09-18-2008, 09:30 PM
HD Newbie
 
Join Date: Sep 2008
Posts: 6

Status: vendetta is offline
How could I do this if I have a Windows server?
 
 
 


Old
  Post #6 (permalink)   09-26-2008, 01:11 AM
HD Newbie
 
Join Date: Sep 2006
Posts: 41

Status: alvarez16 is offline
I'm wondering the same thing ^^^

Thanks
__________________
Premium Shared and Reseller Web Hosting
cPanel and WHM Reseller Control Panel
Tons of Web Space and Bandwidth, and Unlimited Features

www.layeredzonehosting.com
 
 
 


Old
  Post #7 (permalink)   10-15-2008, 01:43 PM
HD Newbie
 
Join Date: Oct 2008
Location: LowCostWebHosting.org
Posts: 15

Status: brobee is offline
You would do it on a Windows server by going into IIS, select the website in question and on the security tab set the ip restrictions.

You can check this post online:
http://forums.devshed.com/iis-97/blo...0t-161146.html
__________________
View and review low cost web hosting companies.
 
 
 


Old
  Post #8 (permalink)   11-23-2008, 10:49 PM
HD Newbie
 
Join Date: Oct 2008
Location: Florida
Posts: 26

Status: jcarney1987 is offline
Yeah if I wanted to ban them I just ban them in my php scripts.
__________________
Quality Shared Hosting & Service With Competitive Prices!
99.9% uptime CPanel 30 Day Money Back Guarantee 24-7 Support!
Email me @ j.carney@jmchosting.com for any comments or questions!
JMC Hosting For All Your Web Based Needs!
 
 
 


Old
  Post #9 (permalink)   11-27-2008, 11:54 PM
HD Amateur
 
Join Date: Oct 2008
Posts: 66

Status: hzSari is offline
The specific block for the ip can be made via the IIS manager :


In IIS Manager, double-click the local computer; right-click the Web Sites or FTP Sites folder, an individual Web or FTP site, a virtual directory, or a file; and then click Properties.

Configuration settings made at the Web or FTP Sites level are inherited by all of the Web or FTP sites on the server. You can override inheritance by configuring the individual site or site element.

Granted access or Denied access. When you select Denied access, you deny access to all computers and domains, except to those that you specifically grant access. When you select Granted access, you grant access to all computers and domains, except to those that you specifically deny access.
__________________
hzSari | HostingZoom.com
ModVPS.com | ResellerZoom.com
Power Speed Reliability
 
 
 


Old
  Post #10 (permalink)   11-28-2008, 04:30 PM
HD Wizard
 
romes's Avatar
 
Join Date: Feb 2007
Location: IL
Posts: 1,444
Send a message via MSN to romes

Status: romes is offline
Thanks for the share mate.
__________________
RomesBlog.net | Xbox 360 Gaming Articles, Add-ons, New Releases and Much More!
Gaming Directory | Directory on the blog | Great source of traffic! | Reciprocal Link for PR2+ Sites | Advertise for FREE!
 
 
 


Old
  Post #11 (permalink)   11-29-2008, 06:18 AM
HD Addict
 
Join Date: Nov 2008
Location: Bombay
Posts: 157
Send a message via ICQ to genesis Send a message via AIM to genesis Send a message via MSN to genesis Send a message via Yahoo to genesis Send a message via Skype™ to genesis

Status: genesis is offline
very good,keep the info flowing in,
__________________
Webhosting-10.com
The Web Hosting Reviews Place, Web hosting Is an Art.
+WEBHOSTING-10 Is Now a Page Rank 6+
 
 
 


Old
  Post #12 (permalink)   12-12-2008, 02:02 PM
VPS Wizard
 
Digitallinx's Avatar
 
Join Date: Sep 2008
Posts: 55
Send a message via AIM to Digitallinx Send a message via MSN to Digitallinx

Status: Digitallinx is offline
Note that having a lot of blocked IP addresses in a .htaccess file, apache will hog resources as it will take time to open the file go through it all and take proper action and it has to do that on each visit so you will experience slow loading times and high ram & cpu usage, especially if you have a busy site.
__________________
VPS Hosting
VPS Affiliate Program 110% Commission
New VPS reseller program available
The opinions expressed on this site are my own and do not necessarily represent those of my employer
 
 
 
Reply

Thread Tools

New Post New Post   Old Post Old Post
Posting Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Sponsored By: