From: Eugene Grosbein <Eugene.Grosbein@f1.n5006.z2.fidonet.org>
Date: Mon, 13 Nov 2000 11:46:13 +0300
Subject: ограничение входящих соеденений с 1 IP в apache
X-newsgroup: fido.ru.unix
Sun, 12 Nov 2000 20:47:16 +0700, Sergey Shibeko написал(а):
>Каким образом ограничить количество входящих соеденений с одного
>адреса в apache? Hужно, чтобы любители многопотоковых качалок не
>получили преимущиства.
>Возможно ли сделать это для виртуального сервера?
Есть патч к сорцам, вводящий команды MaxServersPerIP и MaxServersPerIPRead.
Автор его почему-то привязал к 1.3.9rusPL29.0. У меня PL29.2,
так я его просто подправил под это имя - работает уже давно.
diff -ur apache_1.3.9rusPL29.2/src/include/http_conf_globals.h
apache_1.3.9rusPL29.2-patch/src/include/http_conf_globals.h
- --- apache_1.3.9rusPL29.2/src/include/http_conf_globals.h Sat Aug 21 02:44:56
1999
+++ apache_1.3.9rusPL29.2-patch/src/include/http_conf_globals.h Tue Sep 21
17:34:52 1999
@@ -86,6 +86,8 @@
extern int ap_daemons_limit;
extern MODULE_VAR_EXPORT int ap_suexec_enabled;
extern int ap_listenbacklog;
+extern int ap_daemons_max_by_ip;
+extern int ap_daemons_max_by_ip_read;
extern int ap_dump_settings;
extern API_VAR_EXPORT int ap_extended_status;
+void update_child_status_remote_ip (int, conn_rec *);
+int count_connections (conn_rec *, int);
+
#ifndef NO_OTHER_CHILD
/*
* register an other_child -- a child which the main loop keeps track of
diff -ur apache_1.3.9rusPL29.2/src/include/httpd.h
apache_1.3.9rusPL29.2-patch/src/include/httpd.h
- --- apache_1.3.9rusPL29.2/src/include/httpd.h Thu Sep 2 22:59:02 1999
+++ apache_1.3.9rusPL29.2-patch/src/include/httpd.h Tue Sep 21 17:34:53 1999
@@ -297,6 +297,12 @@
#define DEFAULT_MIN_FREE_DAEMON 5
#endif
+/* Define default limits for MaxDaemons serving a single address */
+
+#define DEFAULT_MAX_DAEMONS_BY_IP 150
+#define DEFAULT_MAX_DAEMONS_BY_IP_READ 75
+#define LIMIT_CONNECTIONS_BY_IP_ERROR HTTP_SERVICE_UNAVAILABLE
+
/* Limit on the total --- clients will be locked out if more servers than
* this are needed. It is intended solely to keep the server from crashing
* when things get out of hand.
diff -ur apache_1.3.9rusPL29.2/src/include/scoreboard.h
apache_1.3.9rusPL29.2-patch/src/include/scoreboard.h
- --- apache_1.3.9rusPL29.2/src/include/scoreboard.h Sat Aug 21 02:45:00 1999
+++ apache_1.3.9rusPL29.2-patch/src/include/scoreboard.h Tue Sep 21 17:34:53
1999
@@ -159,6 +159,7 @@
char request[64]; /* We just want an idea... */
server_rec *vhostrec; /* What virtual host is being accessed? */
/* SEE ABOVE FOR SAFE USAGE! */
+ unsigned long remoteip;
} short_score;