Skip to content

Slowloris

CdFerneding edited this page Aug 17, 2023 · 1 revision

Slowloris

Angriff indentifizieren

netstat -nalt | grep :80 | grep ESTA -c

zählt aktive Verbindungen

netstat -nalt | grep :80 | grep ESTA gibt die VErbindungen aus

NGINX worker connections limit

liegt bei /etc/nginx/nginx.conf

anpassen von

events {
    worker_connections 768;
}

zu

events {
    worker_connections 100000;
}

system open file limit

überprüfen mit

cat /proc/sys/fs/file-max

max@webbaki-entwicklung:/etc/nginx$ cat /proc/sys/fs/file-max
9223372036854775807

ist groß genug...

Wenn nicht, dann in

/etc/sysctl.conf

auf

fs.file-max = 500000

setzen

user’s open file limit

in www-data console gehen; hat keine shell, deshalb das -s

sudo su - www-data -s /bin/bash

Limit:

ulimit -n

Hard Limit:

ulimit -Hn

Soft Limit:

ulimit -Sn

Normalerweise ist das Soft Limit bei 1024 und das Hard Limit bei 4096.

Wenn ja, dann unter

/etc/security/limits.conf

anheben auf:

*                soft    nofile          102400
*                hard    nofile          409600
www-data         soft    nofile          102400
www-data         hard    nofile          409600

NGINX’s worker number of open files limit

nginx limitiert die Anzahl der open files auch ... also anpassen

ps aux | grep nginx

dann kommt etwas ähnliches wie das raus:

root      1095  0.0  0.0  85880  1336 ?        Ss   18:30   0:00 nginx: master process /usr/sbin/nginx
www-data  1096  0.0  0.0  86224  1764 ?        S    18:30   0:00 nginx: worker process
www-data  1097  0.0  0.0  86224  1764 ?        S    18:30   0:00 nginx: worker process
www-data  1098  0.0  0.0  86224  1764 ?        S    18:30   0:00 nginx: worker process
www-data  1099  0.0  0.0  86224  1764 ?        S    18:30   0:00 nginx: worker process

Eine www-data id nehmen (z.B. 1095) und benutzen:

cat /proc/1096/limits

Max open files            1024                 4096                 files

Max open files ist noch bei 1024

/etc/nginx/nginx.conf

worker_rlimit_nofile 102400;

einfügen

Sollte ungefähr so aussehen:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

worker_rlimit_nofile 102400; 

events{ ...

unbedingt am Anfang vor den envents eintragen.