Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Hi I want to black my server from any contact with a black list of ips and I would also like to block any domain names if possible, and have it only send http headers back and forth between ip addresses!

I would like to pretty much block any dataleaks to outside except serving the users that have a valid php session! I'm using a lot of code I download just to learn and I dont know where the people who post these have got them from or what kinda backdoors they have put in there so I would like to make sure I'm not gonna get in trouble for using anything I wasn't supposed to because of license and copyright issues!

share|improve this question

migrated from stackoverflow.com Jul 28 '10 at 1:46

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

To block certain IP addresses (or hostnames) from accessing your website, you could use Apache's Allow and Deny directives, something like what sukru said. But it's often considered more secure to completely block any communication (not just website access) between the selected IPs and your server - after all, if you have reason enough to keep them from accessing your website, you probably don't want them accessing other stuff on your server either. To enforce that kind of access, you'll have to use IPtables. There are many IPtables references online; I happen to have written one which might be of some use to you. The relevant commands would be

iptables -I INPUT --source xxx.xxx.xxx.xxx -j DROP
iptables -I OUTPUT --destination xxx.xxx.xxx.xxx -j DROP

where xxx.xxx.xxx.xxx is the IP address you want to block. Run both these commands for each such address.

share|improve this answer
add comment

You need to update httpd.conf (or .htaccess if sufficient options are enabled)

<Location /url>
  Order allow,deny
  Allow from all
  Deny from host1
  Deny from host2
  Deny from *.domain
  ...etc
</Location>

From documentation: link

Allow,Deny First, all Allow directives are evaluated; at least one must match, or the request is rejected. Next, all Deny directives are evaluated. If any matches, the request is rejected. Last, any requests which do not match an Allow or a Deny directive are denied by default.

share|improve this answer
    
Um... don't you mean Order deny,allow? Because what you have would enable communication with all hosts. –  David Z Jul 27 '10 at 4:29
1  
Nope, the documentation specifically says it's the opposite, there is even a table in the linked page which shows the results when both a deny and allow rule matches. –  sukru Jul 27 '10 at 5:53
    
Huh, I thought I remembered reading otherwise. You're right though. –  David Z Jul 28 '10 at 5:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.