How to Safeguard Apache Web Server on Ubuntu

Setup Apache Web Server

$ sudo apt-get install apache2
http://ip_address

Creating ModEvasive Log Directory

$ sudo mkdir /var/log/mod_evasive
$ sudo chown -R www-data:www-data /var/log/mod_evasive
$ sudo systemctl restart apache2

Testing ModEvasive

$ sudo nano /usr/share/doc/libapache2-mod-evasive/examples/test.pl
print $SOCKET "GET /?$_ HTTP/1.0\n\n";
print $SOCKET "GET /?$_ HTTP/1.0\r\nHost: 127.0.0.1\r\n\r\n";
$ sudo perl /usr/share/doc/libapache2-mod-evasive/examples/test.pl
...
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 403 Forbidden
HTTP/1.1 403 Forbidden
HTTP/1.1 403 Forbidden
HTTP/1.1 403 Forbidden
..
$ sudo ls -a /var/log/mod_evasive
.  ..  dos-127.0.0.1
$ sudo tail /var/log/apache2/error.log
...
[evasive20:error] [pid 31967] [client 127.0.0.1:43954] client denied by server configuration: /var/www/html/.
...

Related Blog Posts

Related Market Product

Related Documentation

Related Products

Related Course

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store