Skip to content

Commit c3e36c6

Browse files
author
enoch85
committed
add extra security
1 parent 2c39a44 commit c3e36c6

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

static/security.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
# Tech and Me, ©2016 - www.techandme.se
4+
5+
# Based on: http://www.techrepublic.com/blog/smb-technologist/secure-your-apache-server-from-ddos-slowloris-and-dns-injection-attacks/
6+
7+
SPAMHAUS=/etc/spamhaus.wl
8+
ENVASIVE=/etc/apache2/mods-available/mod-evasive.load
9+
APACHE2=/etc/apache2/apache2.conf
10+
11+
set -e
12+
13+
# Protect against DDOS
14+
apt-get -y install libapache2-mod-evasive
15+
mkdir -p /var/log/apache2/evasive
16+
chown -R www-data:root /var/log/apache2/evasive
17+
if [ -f $ENVASIVE ];
18+
then
19+
echo "Envasive mod exists"
20+
else
21+
touch $ENVASIVE
22+
cat << ENVASIVE > "$ENVASIVE"
23+
DOSHashTableSize 2048
24+
DOSPageCount 20 # maximum number of requests for the same page
25+
DOSSiteCount 300 # total number of requests for any object by the same client IP on the same listener
26+
DOSPageInterval 1.0 # interval for the page count threshold
27+
DOSSiteInterval 1.0 # interval for the site count threshold
28+
DOSBlockingPeriod 10.0 # time that a client IP will be blocked for
29+
DOSLogDir
30+
ENVASIVE
31+
fi
32+
33+
# Protect against Slowloris
34+
apt-get -y install libapache2-mod-qos
35+
36+
# Protect against DNS Injection
37+
apt-get -y install libapache2-mod-spamhaus
38+
if [ -f $SPAMHAUS ];
39+
then
40+
echo "Spamhaus mod exists"
41+
else
42+
touch $SPAMHAUS
43+
cat << SPAMHAUS >> "$APACHE2"
44+
45+
# Spamhaus module
46+
<IfModule mod_spamhaus.c>
47+
MS_METHODS POST,PUT,OPTIONS,CONNECT
48+
MS_WhiteList /etc/spamhaus.wl
49+
MS_CacheSize 256
50+
</IfModule>
51+
SPAMHAUS
52+
fi
53+
54+
service apache2 restart
55+
if [[ $? > 0 ]]
56+
then
57+
echo "Something went wrong..."
58+
sleep 5
59+
exit 1
60+
else
61+
echo "Security added!"
62+
exit 0
63+
fi

wordpress_install.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ allow from all
251251
</Files>
252252
EOL
253253

254+
# Add extra security
255+
wget -q $STATIC/security.sh -P $SCRIPTS
256+
bash $SCRIPTS/security.sh
257+
rm $SCRIPTS/security.sh
258+
254259
# Change values in php.ini (increase max file size)
255260
# max_execution_time
256261
sed -i "s|max_execution_time = 30|max_execution_time = 3500|g" /etc/php/7.0/cli/php.ini

0 commit comments

Comments
 (0)