{"id":484,"date":"2022-06-10T14:08:53","date_gmt":"2022-06-10T17:08:53","guid":{"rendered":"https:\/\/xaxowareti.com.br\/?p=484"},"modified":"2022-06-10T14:08:57","modified_gmt":"2022-06-10T17:08:57","slug":"squid-proxy-on-pfsense-for-home-web-cache-and-security","status":"publish","type":"post","link":"https:\/\/xaxowareti.com.br\/?p=484","title":{"rendered":"Squid Proxy on pfSense for Home Web Cache and Security"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">About my setup<\/h2>\n\n\n\n<p>I have a pfSense box running&nbsp;<strong>2.2.5-RELEASE&nbsp;<\/strong>(amd64), Squid 3.4 branch, and SquidGuard.<\/p>\n\n\n\n<p>To customize the refresh rules, go to Services menu, select Squid proxy. Select the Local cache tab.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/www.psynapticmedia.com\/wp-content\/uploads\/2015\/12\/2015-12-09_11-32-58.jpg\"><img decoding=\"async\" src=\"http:\/\/www.psynapticmedia.com\/wp-content\/uploads\/2015\/12\/2015-12-09_11-32-58-450x226.jpg\" alt=\"2015-12-09_11-32-58\" class=\"wp-image-12855\"\/><\/a><\/figure>\n\n\n\n<p>At the bottom, enter the custom code in the\u201dCustom refresh_patterns\u201d box.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Download config<\/h2>\n\n\n\n<p><a href=\"http:\/\/www.psynapticmedia.com\/wp-content\/uploads\/2016\/12\/psynaps-pfsense-squid3-example.txt\" target=\"_blank\" rel=\"noreferrer noopener\">psynaps-pfsense-squid3-example.txt<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Config<\/h2>\n\n\n\n<p>(updated 12-09-15)<\/p>\n\n\n\n<p># 1 year = 525600 mins, 1 month = 43800 mins, 1 week = 10080 min, 1 day = 1440 min<\/p>\n\n\n\n<p>#Optional: dont cache wordpress admin panel<br>refresh_pattern (wp-admin)&nbsp; 0 0% 0<\/p>\n\n\n\n<p># specific cache<br># live_user: twitch preview thumbs<br>refresh_pattern -i (live_user) 30 60% 300 override-lastmod reload-into-ims<br># for malwarebytes update checking<br>refresh_pattern -i (mbamupdates.com) 1440 60% 10080 override-lastmod reload-into-ims<\/p>\n\n\n\n<p>#All File<br>refresh_pattern -i \\.(3gp|7z|ace|asx|avi|bin|cab|dat|deb|rpm|divx|dvr-ms)(\\?|$) 43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload<br>refresh_pattern -i \\.(rar|jar|gz|tgz|tar|bz2|iso)(\\?|$)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload<br>refresh_pattern -i \\.(m1v|m2(v|p)|mo(d|v)|(x-|)flv)(\\?|$)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload<br>refresh_pattern -i \\.(jp(e?g|e|2)|gif|pn[pg]|bm?|tiff?|ico|swf)(\\?|$)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload<br>refresh_pattern -i \\.(mp(e?g|a|e|1|2|3|4)|mk(a|v)|ms(i|u|p))(\\?|$)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload<br>refresh_pattern -i \\.(og(x|v|a|g)|rar|rm|r(a|p)m|snd|vob|wav)(\\?|$)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload<br>refresh_pattern -i \\.(pp(s|t)|wax|wm(a|v)|wmx|wpl|zip|cb(r|z|t))(\\?|$)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload<br>refresh_pattern -i \\.(woff|txt|exe|dmg|webm)(\\?|$)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 43800 100% 129600 ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload<br>refresh_pattern -i \\.(css)(\\?|$)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10080&nbsp; 60% 43800&nbsp; ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload<br>refresh_pattern -i \\.(js)(\\?|$)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10080&nbsp; 60% 10080&nbsp; ignore-no-cache ignore-no-store ignore-private override-expire override-lastmod reload-into-ims ignore-reload<\/p>\n\n\n\n<p>refresh_pattern -i \\.(html|htm)(\\?|$) 1440&nbsp; 60% 10080 ignore-no-cache ignore-no-store ignore-private override-expire reload-into-ims<br>refresh_pattern -i \\.(doc|pdf)(\\?|$)&nbsp; 10080 90% 43200 ignore-no-cache ignore-no-store ignore-private override-expire reload-into-ims<\/p>\n\n\n\n<p>refresh_pattern -i \\.(cdn) 10800 100% 43800 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-private<br>refresh_pattern -i (cdn)&nbsp;&nbsp; 10800 100% 43800 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-private<\/p>\n\n\n\n<p>refresh_pattern \\.ytimg\\? 10800 90% 10800 override-expire ignore-reload ignore-no-cache<br>refresh_pattern ^http:\/\/*.facebook.com\/* 720 100% 4320<br>refresh_pattern ^http:\/\/mail.yahoo.com\/.* 720 100% 4320<br>refresh_pattern ^http:\/\/*.yahoo.*\/.* 720 100% 4320<br>refresh_pattern ^http:\/\/*.yimg.*\/.* 720 100% 4320<br>refresh_pattern ^http:\/\/*.gmail.*\/.* 720 100% 4320<br>refresh_pattern ^http:\/\/*.google.*\/.* 720 100% 4320<br>refresh_pattern ^http:\/\/*.kaskus.*\/.* 720 100% 4320<br>refresh_pattern ^http:\/\/*.googlesyndication.*\/.* 720 100% 4320<br>refresh_pattern ^http:\/\/*.plasa.*\/.* 720 100% 4320<br>refresh_pattern ^http:\/\/*.telkom.*\/.* 720 100% 4320<\/p>\n\n\n\n<p>#catch all<br>refresh_pattern . 360 90% 1440 override-lastmod reload-into-ims<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">More details<\/h2>\n\n\n\n<p>To make the cache more aggressive, i used (\\?|$). by adding \/?, this caches objects when the URL ends in ? (example abc.css?). Typically a ? is used to indicate dynamic content, and is also used to instruct caches to NOT cache those objects, so be careful using this. However, I found it is OK to ignore the ? after objects like jpgs and css, and many times js. These objects are static content, and most of the time they do not change and can be cached for long periods of time. Caching these kinds of objects is great, because it reduces the number of requests you make to the web. I also use the $ option above. This means its the end of the string, so \\.jpg$ just matches an object with .jpg at the end of the URL.<\/p>\n\n\n\n<p>I use a catch all. The function of this rule is to match any requests that have not already matched the rules above. Be careful here, because this rule can\/will cache dynamic content. The default pfsense Squid catchall exists in the default config already, however, the built-in config is not editable (as far as I understand). It will always revert to default (let me know if you know how to change that). Thus, to work-around I can simply add and customize the catch all at the bottom of my \u201cCustom refresh_patterns\u201d.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>About my setup I have a pfSense box running&nbsp;2.2.5-RELEASE&nbsp;(amd64), Squid 3.4 branch, and SquidGuard. To customize the refresh rules, go to Services menu, select Squid proxy. Select the Local cache tab. At the bottom, enter the custom code in the\u201dCustom refresh_patterns\u201d box. Download config psynaps-pfsense-squid3-example.txt Config (updated 12-09-15) # 1 year = 525600 mins, 1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-484","post","type-post","status-publish","format-standard","hentry","category-sem-categoria"],"_links":{"self":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts\/484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=484"}],"version-history":[{"count":1,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts\/484\/revisions"}],"predecessor-version":[{"id":485,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts\/484\/revisions\/485"}],"wp:attachment":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}