Category Archives: apache2
Syntax error on line 52 of /etc/modsecurity/activated_rules/modsecurity_crs_20_protocol_violations.conf: SOLVED
During the configuration of owasp modsecurity core rule set (CRS) the following error appeared
Syntax error on line 52 of /etc/modsecurity/activated_rules/modsecurity_crs_20_protocol_violations.conf:
The main reasons are the previously installed version of libapache2-modsecurity and OWASP CRS.
dpkg -s libapache2-modsecurity | grep Version
Version: 2.6.6-6+deb7u1
owasp-modsecurity-2.2.8-1
libapache2-modsecurity version 2.6.6-6 doesn’t work correctly with owasp csr 2.2.8-1
The earlier version of owasp core rule set is needed.
and here it is a basic configuration of apache modsecurity
aptitude install libapache2-modsecurity
cp /etc/modsecurity/modsecurity.conf-recommended /etc/apache2/conf.d/modsecurity.conf
vim /etc/apache2/conf.d/modsecurity.conf
customize settings
SecRuleEngine DetectionOnly
SecRequestBodyAccess On
SecDebugLog /var/log/apache2/modsecurity-debug.log
SecDebugLogLevel 3
a2enmod mod-security
a2enmod headers
apachectl configtest
/etc/init.d/apache2 reload
Now configure owasp mod-security
wget https://github.com/SpiderLabs/owasp-modsecurity-crs/tarball/v2.2.5
tar xvf v2.2.5
cp -r SpiderLabs-owasp-modsecurity-crs-5c28b52/* /etc/modsecurity/
mv /etc/modsecurity/modsecurity_crs_10_setup.conf.example /etc/modsecurity/modsecurity_crs_10_setup.conf
cd /etc/modsecurity/base_rules/
for f in * ; do ln -s /etc/modsecurity/base_rules/$f /etc/modsecurity/activated_rules/$f;done
cd /etc/modsecurity/optional_rules/
for f in * ; do ln -s /etc/modsecurity/optional_rules/$f /etc/modsecurity/activated_rules/$f; done
vim /etc/apache2/mods-available/mod-security.conf
add owasp config files
Include "/etc/modsecurity/activated_rules/*.conf"
apachectl configtest
/etc/init.d/apache2 reload
permalinks /%postname%/ error 404 not found in wordpress
During the hosting migration a wordpress cms, there was a problem with permalinks and postnames, when you try to access a random categories the error 404 not found appears.
To solve the problem make sure your virtualhost looks like that.
Options +FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
In the wordpress cms, navigate to Tools->Permalinks->Custom Structur ( /%postname%/ )
This is output generated from wordpress cms .htaccess file
BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
PHP Fatal error: Call to undefined function bcsub()
PHP Fatal error: Call to undefined function bcsub()
yum install php-bcmath.x86_64
PHP Fatal error: Call to undefined function mb_internal_encoding()
PHP Fatal error: Call to undefined function mb_internal_encoding()
it’s seems missing php extension
yum install php-mbstring
301 .htaccess redirect
Sometimes we need to redirect old links to new pages, it`s very easy.
Redirect 301 /oldpage.php http://newlink/newpages.php
apache connections
count the apache connections
netstat -nt | grep :80 | wc -l
show number of connections for each ip address
netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort –
netstat -an|awk ‘/tcp/ {print $6}’|sort|uniq -c
mod_evasive prevent DOS attacks on apache webserver
aptitude search mod-evasive
p libapache2-mod-evasive – evasive module to minimize HTTP DoS or brute force attacks
aptitude install libapache2-mod-evasive
mkdir -p /var/log/apache2/evasive
chown -R www-data:root /var/log/apache2/evasive/
vim /etc/apache2/mods-available/mod-evasive.load
LoadModule evasive20_module /usr/lib/apache2/modules/mod_evasive20.so
DOSHashTableSize 3097
DOSPageCount 5
DOSSiteCount 100
DOSPageInterval 2
DOSSiteInterval 2
DOSBlockingPeriod 600
DOSLogDir “/var/log/apache2/evasive”
DOSEmailNotify [email protected]
apachectl configtest
Syntax OK
apachectl restart
http load testing and benchmarking utilities
apt-get install jmeter-http
apt-get install siege
apt-get install httperf
No such file or directory: Failed to enable the ‘httpready’ Accept Filter
зареждаме драйвера
kldload accf_http
BSD# /usr/local/etc/rc.d/apache22 restart
Performing sanity check on apache22 configuration:
Syntax OK
Stopping apache22.
Waiting for PIDS: 55392.
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.
добавяме го да се изпълнява при стартирането на системата
BSD# echo ‘accf_http_load=”YES”‘ >> /boot/loader.conf