基于ipfw的防火墙会降低Apache Web服务器的速度

我有一台运行在FreeBSD 8.3机器上的Apache web服务器。
该机器具有这些规则的ipfw防火墙:

root@aigamedev:~# ipfw -a list 00005 0 0 deny ip from 67.212.xxx.xxx to any 00010 206 88422 allow ip from any to any via lo0 00015 0 0 deny ip from any to 127.0.0.0/8 00020 0 0 deny ip from 127.0.0.0/8 to any 00050 0 0 check-state 00060 5315 1358507 allow tcp from any to any established 00061 8 658 allow ip from any to any out keep-state 00070 0 0 allow icmp from any to any 00080 0 0 deny ip from me to me in recv re0 00085 0 0 deny tcp from any to any frag 00098 0 0 allow tcp from me to 83.64.xxx.xxx out established keep-state 00099 0 0 allow tcp from 83.64.xxx.xxx to me dst-port 22 in setup keep-state 00100 0 0 allow tcp from any to any dst-port 22 in setup keep-state 00110 0 0 allow tcp from any to any dst-port 22 out setup keep-state 00160 0 0 allow tcp from any to any dst-port 25 out setup keep-state 00180 0 0 allow tcp from any to any dst-port 53 out setup keep-state 00185 0 0 allow udp from any to any dst-port 53 out keep-state 00200 6750 661150 allow tcp from any to any dst-port 80,443 in setup keep-state 00210 0 0 allow tcp from any to any dst-port 80,443 out setup keep-state 00250 0 0 allow udp from any to any dst-port 123 out keep-state 00280 0 0 allow udp from any to any dst-port 67-68 out keep-state 00300 0 0 allow tcp from any to any dst-port 5222,5223,5269 in setup keep-state 00305 0 0 allow tcp from any to any dst-port 5222,5223,5269 out setup keep-state 00999 25 1716 deny ip from any to any 65535 0 0 deny ip from any to any 

只要启用这些防火墙规则,同一台计算机上的Apache服务器“变慢”,即多个连接挂起,页面需要几秒钟才能加载,而不是ms。 这可以从不同的源networking和客户端进行testing。 在server-status我可以看到许多(大部分)Apache插槽处于阅读状态,无所事事。

当我停止防火墙时,Apache服务器立即恢复正常的性能

任何想法这些防火墙规则可能是错误的?

你是否允许TCP / 80“新”连接? Apache正在监听什么端口,以及接受连接的位置?

这些规则不应该导致任何放缓:

 00200 allow tcp from any to any dst-port 80,443 in setup keep-state 00210 allow tcp from any to any dst-port 80,443 out setup keep-stat 

也许这些港口正在对这些港口上的脚本/达蒙/应用程序征税,并且正在放慢速度。

 00300 allow tcp from any to any dst-port 5222,5223,5269 in setup keep-state 00305 allow tcp from any to any dst-port 5222,5223,5269 out setup keep-state 

我的build议是:每个服务有一个物理/虚拟机…..运行ntop,看你有多lessstream量实际上是推动

这听起来像Apache依赖于防火墙阻止的其他服务。 不知道你正在运行的应用程序,很难给出更准确的信息,但是你阻止访问localhost上的所有东西,这似乎是错误的。

首先注释掉所有的拒绝行,并确保它以相同的速度运行。 然后慢慢开始重新添加拒绝行,从结束开始。 尽pipe这些规定声称不会被触发,但并不总是如此可靠。