Update README.md

Used Markdown to make the instructions more readable.
This commit is contained in:
Scott Wallace 2013-06-25 18:49:33 +02:00
parent 5f3dbc4e5a
commit d58959b834

View file

@ -1,43 +1,68 @@
# Compilation # Compilation
1. Ensure the SQLite development libraries (sqlite-devel) are installed. 1. Ensure the SQLite development libraries (sqlite-devel) are installed.
2. Either run the `build_from_scratch.sh` script or run the following commands: 2. Either run the `build_from_scratch.sh` script or run the following commands:
1. `libtoolize`
2. `aclocal` ```Shell
3. `autoconf` libtoolize
4. `automake -a` aclocal
5. `./configure --with-apache=<Apache location>` autoconf
6. `make CFLAGS=-lsqlite3` automake -a
./configure --with-apache=<Apache location>
make CFLAGS=-lsqlite3
```
# Installation # Installation
1. Activate in Apache using: 1. Activate in Apache using:
* (automatic) Using APXS: * (automatic) Using APXS:
```
```Shell
apxs -i -a -n blockinator libmodblockinator.la apxs -i -a -n blockinator libmodblockinator.la
``` ```
_*or*_
_*or*_
* (manual) Add the following commands to the Apache configuration: * (manual) Add the following commands to the Apache configuration:
```
```ApacheConf
LoadModule blockinator_module modules/libmodblockinator.so LoadModule blockinator_module modules/libmodblockinator.so
``` ```
2. Configure mod\_blockinator by adding the following lines in the appropriate location(s):
2. Configure mod_blockinator by adding the following lines in the appropriate location(s):
1. Define where the blocklist DB can be found: 1. Define where the blocklist DB can be found:
```
```ApacheConf
<IfModule blockinator_module> <IfModule blockinator_module>
BlockinatorBlocklistDB /path/to/blocklist.db BlockinatorBlocklistDB /path/to/blocklist.db
</IfModule> </IfModule>
``` ```
2. Create a mod\_rewrite rule to block requests, if matched:
``` 2. Create a mod_rewrite rule to block requests, if matched:
```ApacheConf
RewriteCond %{HTTP:X-Block} 1 RewriteCond %{HTTP:X-Block} 1
RewriteRule . - [R=403,L] RewriteRule . - [R=403,L]
``` ```
3. Create the SQLite DB: 3. Create the SQLite DB:
1. `sqlite3 /path/to/blocklist.db` 1. Start SQLite3 on a new file:
2. Run the following SQL:
```Shell
sqlite3 /path/to/blocklist.db
``` ```
2. Run the following SQL:
```SQL
CREATE TABLE IF NOT EXISTS blocklist(remote_ip VARCHAR(15), forwarded_ip VARCHAR(15), useragent VARCHAR(256), cookie VARCHAR(1024), PRIMARY KEY(remote_ip)); CREATE TABLE IF NOT EXISTS blocklist(remote_ip VARCHAR(15), forwarded_ip VARCHAR(15), useragent VARCHAR(256), cookie VARCHAR(1024), PRIMARY KEY(remote_ip));
``` ```
3. (optional) Insert some test data: 3. (optional) Insert some test data:
Block requests from IP address 1.2.3.4
e.g. ```INSERT INTO blocklist VALUES("1.2.3.4", "ANY", "ANY", "ANY");``` e.g. Block requests from IP address 1.2.3.4
```SQL
INSERT INTO blocklist VALUES("1.2.3.4", "ANY", "ANY", "ANY");
```
4. Restart Apache 4. Restart Apache