Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
# Define the Red Hat paths
APACHE_INCLUDES := -I/usr/include/httpd/
APR_INCLUDES := -I/usr/include/apr-1/

# Check for Debian/Ubuntu paths
ifneq (, $(shell test -d /usr/include/apache2 && echo "true"))
APACHE_INCLUDES := -I/usr/include/apache2
APR_INCLUDES := -I/usr/include/apr-1.0/
endif

CPPFLAGS := $(APACHE_INCLUDES) $(APR_INCLUDES) -fPIC

all: mod_vhost_limit.so

shm.o : shm.cpp
g++ -c -I/usr/include/httpd/ -I/usr/include/apr-1/ -fPIC shm.cpp
g++ -c $(CPPFLAGS) -fPIC shm.cpp

mod_vhost_limit.o : mod_vhost_limit.cpp
g++ -c -I/usr/include/httpd/ -I/usr/include/apr-1/ -fPIC mod_vhost_limit.cpp
g++ -c $(CPPFLAGS) -fPIC mod_vhost_limit.cpp

mod_vhost_limit.so : mod_vhost_limit.o shm.o
g++ -shared -o mod_vhost_limit.so mod_vhost_limit.o shm.o
g++ -shared -o mod_vhost_limit.so mod_vhost_limit.o shm.o

clean:
rm -rf mod_vhost_limit.o mod_vhost_limit.so shm.o
Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,26 @@ total 72
4 -rw-r--r-- 1 root root 3368 Aug 14 10:41 shm.o
```

mod_vhost_limit.so is your module. That's it. Now you have to install it.
This is different for each system, so i will show how to install it in a Fedora install :
`mod_vhost_limit.so` is your module. That's it. Now you have to install it.
This is different for each system, so i will show how to install it in...

## Fedora/Redhat:

```bash
$ cp -f mod_vhost_limit.so /etc/httpd/modules/
$ echo -e "\nLoadModule vhost_limit_module modules/mod_vhost_limit.so" >> /etc/httpd/conf.modules.d/00-base.conf
$ systemctl restart httpd
```

## Debian/Ubuntu:

```bash
$ cp -f mod_vhost_limit.so //usr/lib/apache2/modules/
$ echo -e "\nLoadModule vhost_limit_module modules/mod_vhost_limit.so" >> /etc/apache2/mods-available/vhost_limit.load
$ a2enmod vhost_limit
$ systemctl restart apache2
```

<pre>
$ tail /var/log/httpd/error_log

Expand Down Expand Up @@ -77,8 +89,6 @@ To make it DO something, you need to use the only directive supported (for now)
And restart httpd/apache.
<b>MaxVhostClients</b> will set a maximum number of connections to be accepted for that vhost.

Everytime you get a visit, a per-vhost counter will increment. When that connection is finished, the counter will decrement. In this case, we are limiting the vhost to 3 simultaneous connections, and every excess visit will receive a HTTP_SERVICE_UNAVAILABLE response.
Everytime you get a visit, a per-vhost counter will increment. When that connection is finished, the counter will decrement. In this case, we are limiting the vhost to 3 simultaneous connections, and every excess visit will receive a `HTTP_SERVICE_UNAVAILABLE` response.

> Please note : Using a fastcgi script (e.g. mod_fcgi/php-fpm) might not close the connection immediately after finished. It might take a little longer. So if you are testing, have this in mind before thinking something broke.