<rdf:RDF
    xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
    xmlns:s='http://snipsnap.org/rdf/snip-schema#'
    xml:base='http://bliki.rimuhosting.com/rdf'>
    <s:Comment rdf:about='http://bliki.rimuhosting.com/rdf#comment-knowledgebase/linux/webserver/apache/mod_security-1'
         s:cUser='alicia'
         s:oUser=''
         s:mUser='alicia'>
        <s:name>comment-knowledgebase/linux/webserver/apache/mod_security-1</s:name>
        <s:content>I&apos;ve attached an example ruleset configuration file that has quite a few rules for commonly exploited applications. Feel free to use them or modify as you like.&#xD;&#xA;</s:content>
        <s:mTime>2007-08-14 01:21:39.0</s:mTime>
        <s:cTime>2007-08-14 01:16:37.0</s:cTime>
        <s:commentedSnip>
            <s:Snip rdf:about='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/webserver/apache/mod_security'
                 s:cUser='yves'
                 s:oUser=''
                 s:mUser='yves'>
                <s:name>knowledgebase/linux/webserver/apache/mod_security</s:name>
                <s:content>1 Mod_Security installation howto&#xD;&#xA;&#xD;&#xA;http://www.modsecurity.org&#xD;&#xA;&#xD;&#xA;Modsecurity is indeed a very useful software. It&apos;s a module for Apache to help you protect your site from attacks. From the web site description:&#xD;&#xA;&#xD;&#xA;{quote}What Is ModSecurity?&#xD;&#xA;&#xD;&#xA;ModSecurity is an embeddable web application firewall. It provides protection from a range of attacks against web applications and allows for HTTP traffic monitoring and real-time analysis with no changes to existing infrastructure. {quote}&#xD;&#xA;&#xD;&#xA;If you want to know more, understand how it can protect your server and also be aware the relevant caveats, see:&#xD;&#xA;&#xD;&#xA;http://www.modsecurity.org/projects/rules/index.html&#xD;&#xA;&#xD;&#xA;1.1 Installation notes for RHEL4&#xD;&#xA;&#xD;&#xA;It&apos;s not guaranteed that copy-pasting the commands below will work for you, but please do report any inaccuracies you may have found as per the e-mail address at the bottom of this page.&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;apt-get install httpd-devel apr-devel apr-util-devel pcre-devel&#xD;&#xA;&#xD;&#xA;wget http:\//www.modsecurity.org/download/modsecurity-apache_2.1.5.tar.gz&#xD;&#xA;&#xD;&#xA;tar zxvf modsecurity-apache_2.1.5.tar.gz&#xD;&#xA;&#xD;&#xA;cd modsec*&#xD;&#xA;&#xD;&#xA;cd apache2&#xD;&#xA;&#xD;&#xA; sed -i Makefile -e &apos;s|^top_dir.*|top_dir = /etc/httpd|g&apos;&#xD;&#xA;&#xD;&#xA;make&#xD;&#xA;&#xD;&#xA;service httpd stop&#xD;&#xA;&#xD;&#xA;make install&#xD;&#xA;&#xD;&#xA;cd ..&#xD;&#xA;&#xD;&#xA;mkdir /etc/httpd/conf/modsecurity&#xD;&#xA;&#xD;&#xA;cp -R rules/* /etc/httpd/conf/modsecurity/&#xD;&#xA;&#xD;&#xA;cat &lt;&lt;EOF&gt;&gt; /etc/httpd/conf.d/modsecurity.conf&#xD;&#xA;LoadModule unique_id_module modules/mod_unique_id.so&#xD;&#xA;LoadFile /usr/lib/libxml2.so&#xD;&#xA;LoadModule security2_module modules/mod_security2.so&#xD;&#xA;Include conf/modsecurity/*.conf&#xD;&#xA;EOF&#xD;&#xA;&#xD;&#xA;service httpd start&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;1.1 Configuring and using mod_security&#xD;&#xA;&#xD;&#xA;The configuration is stored in:&#xD;&#xA;&#xD;&#xA;/etc/httpd/conf/modsecurity/&#xD;&#xA;&#xD;&#xA;For example, in the file /etc/httpd/conf/modsecurity/modsecurity_crs_10_config.conf , we can see this line:&#xD;&#xA;&#xD;&#xA;SecDefaultAction &quot;phase:2,log,pass,status:500&quot;&#xD;&#xA;&#xD;&#xA;It sets the default action for rules that don&apos;t have one defined. So I suggest leaving it at the default &quot;log only&quot;, but later change it to &quot;log,deny,status:500&quot; when you feel more confident that there are no rules with false positives.&#xD;&#xA;&#xD;&#xA;You can follow the logs either in the apache error_log or see more detailed output in this file:&#xD;&#xA;&#xD;&#xA;{code:none}&#xD;&#xA;tail -f /var/log/httpd/modsec_audit.log -n200&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;Restart your apache server and after a few minutes, depending on how much access you get, you&apos;ll notice that it&apos;s working already, blocking many undesirable requests. &#xD;&#xA;&#xD;&#xA;Wait a couple more days and then change the default action to &quot;deny&quot;, as explained above.&#xD;&#xA;&#xD;&#xA;Please keep an eye on possible but unlikely false positive rejects that modsecurity may cause for valid user requests.  If a rule appears to be problematic, tweak it a bit or comment it out from your rule set and it should be enough.&#xD;&#xA;&#xD;&#xA;Remember that having an application firewall like modsecurity is not a substitute for having good network firewall rules setup and, most importantly, for having only good and secure code running on your server.&#xD;&#xA;&#xD;&#xA;See also this other very important bliki article: [knowledgebase/Security/Securing Your Server]</s:content>
                <s:mTime>2008-01-25 07:32:45.0</s:mTime>
                <s:cTime>2007-08-08 18:04:45.0</s:cTime>
                <s:comments>
                    <rdf:Bag>
                        <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#comment-knowledgebase/linux/webserver/apache/mod_security-1'/>
                    </rdf:Bag>
                </s:comments>
                <s:snipLinks>
                    <rdf:Bag>
                        <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/webserver/apache'/>
                        <rdf:li rdf:resource='#knowledgebase'/>
                        <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux'/>
                        <rdf:li rdf:resource='#snipsnap-index'/>
                        <rdf:li rdf:resource='#snipsnap-search'/>
                        <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/'/>
                        <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/webserver/apache/'/>
                        <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/webserver/apache/mod_proxy'/>
                        <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/postfixadmin on debian sarge'/>
                        <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/webserver'/>
                        <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/mail/postfix notes'/>
                        <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/misc/dns lookups'/>
                        <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/misc/where has my disk space gone'/>
                        <rdf:li rdf:resource='http://bliki.rimuhosting.com/rdf#knowledgebase/linux/miscapplications/Quicklook'/>
                    </rdf:Bag>
                </s:snipLinks>
                <s:attachments>
                    <rdf:Bag>
                        <rdf:li>
                            <s:Attachment rdf:about='http://bliki.rimuhosting.com/space/knowledgebase/linux/webserver/apache/mod_security/mod_security.conf'
                                 s:fileName='mod_security.conf'
                                 s:contentType='application/octet-stream'
                                 s:size='32952'>
                                <s:date>Tue Aug 14 01:15:21 EDT 2007</s:date>
                            </s:Attachment>
                        </rdf:li>
                    </rdf:Bag>
                </s:attachments>
            </s:Snip>
        </s:commentedSnip>
    </s:Comment>
</rdf:RDF>
