Autores
Etiquetas
software
(31)
Windows
(21)
linux
(21)
Malware
(8)
android
(8)
hardware
(7)
programación
(6)
Kernel
(5)
Wifi
(5)
Networking
(4)
Rootkit
(4)
Ehn-Dev
(3)
Virtualización
(3)
antimalware
(3)
antivirus
(3)
apache
(3)
documental
(3)
herramientas
(3)
mysql
(3)
nvidia
(3)
sistemas operativos
(3)
MAC Adress
(2)
SeguridadWireless
(2)
WLAN_XXX
(2)
aio
(2)
all-in-one
(2)
firefox
(2)
hacking
(2)
ssd
(2)
streaming
(2)
trim
(2)
virus policia
(2)
youtube
(2)
Limitar ancho de banda en Apache
martes, 12 de febrero de 2013 |
Publicado por
el-brujo |
Editar entrada
Ejemplos de módulos que permiten controlar y gestionar el ancho de banda del servidor web Apache2
Tenemos varias opciones
Permite filtrar por vhost, por ip, por ficheros, por directorios, etc
Se compila fácilmente usando apxs2 al igual que muchos otros módulos.
Fichero httpd.conf
Añadir
En el ejemplo limitará el ancho de banda a 150KB/s.
Permite también limitar el ancho de banda del "upload" (velocidad de subida)
Ejemplos:
Limita todos usuarios a un máximo de10Kb/s en el vhost :
Limita usuarios internos (llan) a 1000 kb/s con un mínimo de 50kb/s , y ficheros más grandes de 500kb a 50kb/s.
Limita ficheros con extensión avi y mpg a 20kb/s.
Filtrando por tipo mime (texto) a 5kb/s
Máximo 20 conexiones por ip:
BandWidthModule On
BandWidth all 256000
Descarga:
http://ivn.cl/files/source/mod_bw-0.92.tgz
Creación directorio interno:
Limitar Directorio para ver las estadísticas:
Fichero httpd.conf
Para mejorar el rendimiento:
Limitaría el ancho de banda total a 512 kbps (kiloBIT), con 5 conexiones por segundo demáximo, y 15 conexiones abiertas y activas en total.
Esto limitaría a cada usuario a 15 kilobit/segundo, con 3 conexiones por segundo y 3 conexiones activas en total.
200MB para consumir en 4 semanas (1 mes) y si sobrepasa el tráfico le envíamos a una url de aviso.
Unidades aceptadas en varias directivas:
Descarga:
http://dembol.org/downloads/cband/mod-cband-0.9.7.5.tgz
Tenemos varias opciones
- mod_bandwidth para Apache versión/rama 1.3.x
- mod_bw para Apache versión/rama 2.x
- mod_cband para Apache2
- mod_ratelimit para Apache 2.4.x y 2.5.x
- mod_qos
mod_bw
Funciona tanto en Windows como en GNU/Linux. En Windows es necesaria la librería mod_bw-2.0.54.dllPermite filtrar por vhost, por ip, por ficheros, por directorios, etc
Se compila fácilmente usando apxs2 al igual que muchos otros módulos.
wget http://ivn.cl/files/source/mod_bw-0.92.tgz
tar -zxvf mod_bw-0.92.tgz
cd mod_bw
/usr/local/apache2/bin/apxs2 -i -a -c mod_bw.c
Fichero httpd.conf
Añadir
LoadModule bw_module mod_bw.so
BandWidthModule On ForceBandWidthModule OnBandWidth all 1500000
En el ejemplo limitará el ancho de banda a 150KB/s.
Permite también limitar el ancho de banda del "upload" (velocidad de subida)
Ejemplos:
Limita todos usuarios a un máximo de10Kb/s en el vhost :
BandwidthModule On
ForceBandWidthModule On
Bandwidth all 10240
MinBandwidth all -1
Servername www.ehacker.net
Limita usuarios internos (llan) a 1000 kb/s con un mínimo de 50kb/s , y ficheros más grandes de 500kb a 50kb/s.
BandwidthModule On
ForceBandWidthModule On
Bandwidth all 1024000
MinBandwidth all 50000
LargeFileLimit * 500 50000
Servername www.elhacker.net
Limita ficheros con extensión avi y mpg a 20kb/s.
BandwidthModule On
ForceBandWidthModule On
LargeFileLimit .avi 1 20000
LargeFileLimit .mpg 1 20000
Servername www.elhacker.net
Filtrando por tipo mime (texto) a 5kb/s
BandwidthModule On
AddOutputFilterByType MOD_BW text/html text/plain
Bandwidth all 5000
Servername www.elhacker.net
Máximo 20 conexiones por ip:
BandWidth all 0
MaxConnection all 20
BandWidthModule On
BandWidth all 256000
Descarga:
http://ivn.cl/files/source/mod_bw-0.92.tgz
mod_cband
Instalación:wget http://dembol.org/downloads/cband/mod-cband-0.9.7.5.tgz
tar zxvf mod-cband-0.9.7.4.tgz
cd mod-cband-0.9.7.4
./configure
make
make install
Creación directorio interno:
mkdir /var/run/scoreboard
chown apache:apache /var/run/scoreboard
Limitar Directorio para ver las estadísticas:
SetHandler cband-status
Order deny,allow
Allow from ip
Deny from All
Fichero httpd.conf
LoadModule cband_module /usr/lib/apache2/modules/mod_cband.so
CBandScoreboard /var/run/scoreboard
Para mejorar el rendimiento:
CBandScoreFlushPeriod 1
CBandRandomPulse On
- CBandSpeed 512 5 15
Limitaría el ancho de banda total a 512 kbps (kiloBIT), con 5 conexiones por segundo demáximo, y 15 conexiones abiertas y activas en total.
- CBandRemoteSpeed 15kb/s 3 3
Esto limitaría a cada usuario a 15 kilobit/segundo, con 3 conexiones por segundo y 3 conexiones activas en total.
CBandLimit 200M
CBandScoreboard /var/www/scoreboard
CBandExceededURL http://www.elhacker.net/limite_sobrepasado.html
CBandPeriod 4W
200MB para consumir en 4 semanas (1 mes) y si sobrepasa el tráfico le envíamos a una url de aviso.
Unidades aceptadas en varias directivas:
- velocidad transferencias:
- kbps, Mbps, Gbps – multiples of „bits per second”, respectively: 1024, 1024*1024 and 1024*1024*1024 bps
- kb/s, Mb/s, Gb/s – multiples of „bytes per second”, respectively: 1024, 1024*1024 and 1024*1024*1024 b/s
- defaults to kbps
- quotas transferencia:
- K, M, G – multiples of bytes, respectively: 1000, 1000*1000 and 1000*1000*1000 bytes
- Ki, Mi, Gi – multiples of bytes, respectively: 1024, 1024*1024 and 1024*1024*1024 bytes
- defaults to K
- períodos de tiempo:
- S, M, H, D, W – multiples de segundos: Segundos, Minutos, Horas, Días, Weeks(semanas); respectively: 1, 60, 3600, 86400, 604800 seconds
- defaults to S
CBandSpeed 1Mbps 20 40 CBandRemoteSpeed 512kbps 8 10 CBandClassRemoteSpeed bots_class 50kbps 3 4 CBandClassLimit bots_class 500M
# limit speed of this vhost to 1Mbit/s, 10 request/s, 30 open connections CBandSpeed 1Mbps 10 30 # in addition every remote host connecting to this vhost # will be limited to 200kbit/s, 3 request/s, 3 open connections CBandRemoteSpeed 200kbps 3 3
Descarga:
http://dembol.org/downloads/cband/mod-cband-0.9.7.5.tgz
mod_ratelimit
Ejemplo:Limitadando directorio descargas a 400KiB/s<Location /downloads> SetOutputFilter RATE_LIMIT SetEnv rate-limit 400 </Location>

Entrada más reciente