{"id":74,"date":"2012-03-21T19:25:50","date_gmt":"2012-03-21T19:25:50","guid":{"rendered":"http:\/\/www.aixperts.co.uk\/?p=74"},"modified":"2020-06-02T10:28:22","modified_gmt":"2020-06-02T10:28:22","slug":"squidguard","status":"publish","type":"post","link":"https:\/\/www.aixperts.co.uk\/?p=74","title":{"rendered":"squidGuard guide"},"content":{"rendered":"<p>I have used squidGuard for years, but only a basic set-up based on cut-and-paste from their examples. The reason for this is that that is all there is&#8230; Examples! squidGuard appears to be impossible to find proper documentation for, as even their own website doesn&#8217;t explain how it works. Google doesn&#8217;t seem to know either&#8230;<\/p>\n<p>It is actually very simple, so a quick description of the logic follows.<\/p>\n<p>Within a block, say the <em>default<\/em> block, you must have a <em>pass<\/em> statement and if you want to block anything, you must have a <em>redirect<\/em> statement as well. If you want to rewrite a URL, you need a <em>rewrite<\/em> statement. You can have both <em>redirect<\/em> and\/or <em>rewrite<\/em> in your ACL block but as said, without a redirect, you can&#8217;t block anything.<\/p>\n<p>A block within an ACL, looks like this:<\/p>\n<p><em>default {<\/em><br \/>\n<em>\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 pass\u00a0\u00a0\u00a0 !violence !hacking any<\/em><br \/>\n<em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 rewrite facebook<\/em><br \/>\n<em>\u00a0 \u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 redirect http:\/\/www.site.net\/bad.html<\/em><br \/>\n<em>\u00a0 \u00a0 \u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/em><\/p>\n<p>When the source hits a block, let&#8217;s assume <em>default<\/em>, it will first look for the <em>pass<\/em> statement. It will read from left to right and make a decision based on the first match and exit the pass statement after that. If the first match was <em>none<\/em> or a destination preceded by <em><\/em>&#8216;!&#8217;, squidGuard will then return the <em>redirect<\/em> within the block. (If there is no redirect, squidGuard will do nothing and exit).<\/p>\n<p>A destination is defined as:<\/p>\n<p><em>dest violence {<\/em><br \/>\n<em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 domainlist\u00a0\u00a0\u00a0\u00a0\u00a0 violence\/domains<\/em><br \/>\n<em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 log\u00a0\u00a0\u00a0\u00a0 violence<\/em><br \/>\n<em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 urllist violence\/urls<\/em><br \/>\n<em>}<\/em><\/p>\n<p>and will match any URL in the file <em>urls<\/em> and any domain in the file <em>domains<\/em>. This directory structure and its files can be found under the directory specified with the <em>dbhome<\/em> directive, usually at the beginning of the configuration file. The <em>log<\/em> has any attempts to reach blocked sites listed.<\/p>\n<p>If the match was either &#8216;any&#8217;, &#8216;all&#8217;, or a destination not preceded by &#8216;!&#8217;, squidGuard will execute any rewrite rules in the block on the URL, and exit returning the re-written URL. If there are no rewrite rules in the block, it will do nothing and exit. Both cases means allowing access to the requested URL.<\/p>\n<p>If no destination in the pass statement matches, squidGuard will do nothing and exit, thus allowing squid to fetch the requested page.<\/p>\n<p>So, the line:<\/p>\n<p><em> pass none good !hacking any<\/em><\/p>\n<p>will always block, as it executes the <em>redirect<\/em> as soon as it hits <em>none<\/em>. The line:<\/p>\n<p><em>pass good any !hacking none<\/em><\/p>\n<p>will always pass, as it exits when hitting <em>any<\/em>, if not before.<\/p>\n<p><em>pass local none<\/em><\/p>\n<p>will pass any local destinations listed in the <em>local<\/em> destination.<\/p>\n<p>I think that was the main bit to get out, the magic within source blocks is what&#8217;s not documented. The rest is fairly straight forward. Good luck.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have used squidGuard for years, but only a basic set-up based on cut-and-paste from their examples. The reason for this is that that is all there is&#8230; Examples! squidGuard appears to be impossible to find proper documentation for, as &hellip; <a href=\"https:\/\/www.aixperts.co.uk\/?p=74\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[],"class_list":["post-74","post","type-post","status-publish","format-standard","hentry","category-software"],"_links":{"self":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=74"}],"version-history":[{"count":9,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":210,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions\/210"}],"wp:attachment":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}