LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How I can block a IP to view my web site?? (https://www.linuxquestions.org/questions/linux-networking-3/how-i-can-block-a-ip-to-view-my-web-site-149903/)

AZIMBD03 02-24-2004 06:56 AM

How I can block a IP to view my web site??
 
Hi everybody?

I am using apache 1.3.20-16 on my RH PC, now I would like to deny to access the page virtual host http://me.com from from any viewers of IP address 202.141.191.x PLease anybody help me how i can do this job???




Blues
::o :Pengy: :o

Satriani 02-24-2004 07:19 AM

I think you will need to setup some firewall rules... I don't think you can do that with apache itself.. Or you could write a cgi / php script to check the IP address and take proper action....

Hangdog42 02-24-2004 07:20 AM

You can do it with an iptables rule in your firewall:

iptables -A INPUT -p tcp -s 202.141.191.0/24 --dport 80 -j DROP

This should prevent them from accessing your web server (assuming its running on port 80. If its not, change the rule to match your httpd port). Just make sure this rule is ahead of any other rule that might accept the packets.

Satriani 02-24-2004 07:25 AM

This will prevent any access on port 80 from that IP range...
But i believe you want certain virtual hosts not to be available, but others should be? Then... Wow... That's hard I think...
I should go for some CGI-script / php page when entering your site...

dimitri358 02-24-2004 07:26 AM

I'm not sure i haven't tested it, just read it in theory but if you go to the Apache web page, in the how-to's section

http://httpd.apache.org/docs/howto/auth.html<--here you will find what you want.Read what is says. I believe what you are looking for is there.

Satriani 02-24-2004 07:36 AM

Ahhhhh Dimitri is right on the money!!!
When i read it, i remembered it!
You should indeed read that, and then add something to your httpd.conf's virtualhost section like:
Code:

deny from 202.141.191

AZIMBD03 02-26-2004 03:19 PM

Oh ! I have blocked the IP 202.141.191.x just using following script on access.conf file

<Directory /var/www/html/xyz>
<Limit GET POST>
Oreder mutual-failure
deny from 202.141.191.x
allow from all
</Limit>
</Directory>



Enjoy :tisk:

:Pengy:Blues:Pengy:


All times are GMT -5. The time now is 09:39 PM.