configuring httpd.conf for ip filtering

PowerYoga

Diamond Member
Nov 6, 2001
4,603
0
0
I'm trying to configure some IP blocking on my server and I have some questions about the syntax. I would like to deny a whole IP range of 1.2.3.*, where * is 1-255 since there's been some spambot activity coming from a specific set of addresses.

Under the Directory tag I have:

<Directory /sitename>

stuff

Deny from 1.2.3.1/24
Deny from 4.5.6.7
Deny from etcetcetc

stuff

</Directory>

Is this the right syntax?
 
Feb 25, 2011
16,992
1,621
126
Wouldn't it be better to do this in the firewall? Httpd can block it, but then any other services on the system (SSH, etc.) are still accessible.
 

PowerYoga

Diamond Member
Nov 6, 2001
4,603
0
0
this is actually on a hosted solution and I don't have access to the firewall configurations unfortunately.
 

tomt4535

Golden Member
Jan 4, 2004
1,758
0
76
Do you have access to the software firewall(iptables) on the server? The application can block it fine, but it may be better to block it at a lower level before the traffic even gets to the application.
 

PowerYoga

Diamond Member
Nov 6, 2001
4,603
0
0
Do you have access to the software firewall(iptables) on the server? The application can block it fine, but it may be better to block it at a lower level before the traffic even gets to the application.

I actually don't. The hosted solution doesn't give us access to the software firewall since there are often multiple sites hosted on the VPS owned by different users.

I'm looking at the man page and I have tried already tested (and failed) those, but noticed the comment below:

123.231 // this WON'T work
123.231. //this WILL work

I mentioned previously I'm attempting to block an IP range using this syntax:

Deny from 1.2.3.1/24

Is this not the right way to block 1.2.3.*?
 

PowerYoga

Diamond Member
Nov 6, 2001
4,603
0
0
I have both of those modules declared.

I actually don't have an order allow,deny statement or order deny, allow declaration. I just have the Deny From statements.

The site is being routed through a proxy and load balancer if that matters.
 

PowerYoga

Diamond Member
Nov 6, 2001
4,603
0
0
not available for my hosted solution, or I'd be using it already. They've also requested that we don't install additional firewall solutions as other people share the VPS.
 

Red Squirrel

No Lifer
May 24, 2003
70,354
13,677
126
www.anyf.ca
Yeah I think you did it right.

You need to put order deny,allow though, or order allow,deny. I forget 100% what the difference is, you'll want to read up on it to make sure you put the right one. I think it has to do with priority, so if an IP matches for both allow and deny one takes precedence.

I would also look at maybe putting it in a separate .htaccess or include file just to make it cleaner. It also allows you to dynamically move/add IPs to it easily on the fly since if you put it in httpd.conf it requires a restart
 

KillerBee

Golden Member
Jul 2, 2010
1,750
82
91
I actually don't. The hosted solution doesn't give us access to the software firewall since there are often multiple sites hosted on the VPS owned by different users.

I'm looking at the man page and I have tried already tested (and failed) those, but noticed the comment below:



I mentioned previously I'm attempting to block an IP range using this syntax:

Deny from 1.2.3.1/24

Is this not the right way to block 1.2.3.*?

Deny from 1.2.3.0/24