themactep.com

A home of miscellaneous projects by Paul Philippov.

Notes

How to enhance Apache security and reduce server load

Add following lines to Apache security config. Adjust as needed.

# OBSCURE SERVER ENVIRONMENT
ServerTokens Prod
ServerSignature Off
TraceEnable Off
Header always unset X-Powered-By
Header always unset X-Runtime

# BLOCK EVIL USER-AGENTS
SetEnvIfNoCase User-Agent ^$ keep_out
SetEnvIfNoCase User-Agent Java keep_out
SetEnvIfNoCase User-Agent Jorgee keep_out
SetEnvIfNoCase User-Agent MaMa keep_out
SetEnvIfNoCase User-Agent Morfeus keep_out
SetEnvIfNoCase User-Agent panscient.com keep_out
SetEnvIfNoCase User-Agent Python-urllib keep_out
SetEnvIfNoCase User-Agent revolt keep_out
SetEnvIfNoCase User-Agent "Toata dragostea mea pentru diavola" keep_out
SetEnvIfNoCase User-Agent "Toata dragostea mea pentru iEdi" keep_out
SetEnvIfNoCase User-Agent ZmEu keep_out

<Directory /var/www/>
  <RequireAny>
    <RequireAll>
      Require all granted
      Require not env keep_out
    </RequireAll>
  </RequireAny>
</Directory>

# BLOCK REQUESTS FROM INTRUDERS
RedirectMatch 403 /\$\&
RedirectMatch 403 /\.(bash|git|hg|log|svn|swp|tar)
RedirectMatch 403 /(=|_mm|cgi|cvs|dbscripts|jsp|rnd|userfiles)
RedirectMatch 403 (https?|mailto)\:
RedirectMatch 403 \.(aspx?|dll|htc|htm|php)(\?|$)
RedirectMatch 403 (?i)/(eweb|cute|f?ck|kind|u)editor
RedirectMatch 403 (?i)/(drupal|forum|horde|joomla|pma|phpmyadmin|round|typo3|web(dav|mail)|wordpress|wp(-admin)?)(/|$)
RedirectMatch 403 (?i)/((change)?log|(dev)?info|documentation|history|install|licen[cs]e|readme|ver(sion)?)(\.txt|$)
RedirectMatch 403 /(HNAP1|w00tw00t|\+\+)

# REDIRECT BROKEN REQUESTS
RedirectMatch 301 /.google-analytics.com/ga.js https://www.google-analytics.com/ga.js
RedirectMatch 301 /__utm.gif https://www.google-analytics.com/__utm.gif