avoid OOM

It is possible to DoS the server with massiv call of simple babelweb.
Here we generate the dumpfile only once per minute and a short description top optimize apache2 on Debian (i don't know what you can do, if you use nginx)

Signed-off-by: christiand <fff@chrisi01.de>
This commit is contained in:
christiand 2019-11-16 15:04:42 +01:00
parent d553bfc0df
commit 5b082a9509
2 changed files with 10 additions and 7 deletions

View File

@ -4,12 +4,10 @@ A very simple Babel Web for babeld v1.8
## index.php
The php version for gateways
### Requirements
* php
* netcat-openbsd (ipv6)
## babel.html
The haserl version for slim devices without php
### Requirements
* haserl
* netcat with ipv6 support
## Apache 2 settings
To avoid OOM Killer it's usefull to reduce the MaxConnectionsPerChild on apache2. On Debian open /etc/apache2/mods-enabled/mpm_prefork.conf and reduce MaxConnectionsPerChild.
Do not use more then 10 MaxConnectionsPerChild per Gigabyte RAM on your System

View File

@ -23,7 +23,12 @@
<?php
error_reporting(0);
$file="/tmp/babeldump";
shell_exec('echo "dump" | nc ::1 33123 -q 1 > '.$file.'');
if (filemtime($file) < time()-60) {
shell_exec("rm $file && touch $file");
shell_exec('echo "dump" | nc ::1 33123 -q 0 > '.$file.'');
echo "File generate";
}
$file_handle = fopen($file, 'r');
$set=0;