Posts Tagged ‘ Squid Squalor

The Lolcats, they are everywhere!

Do you use squid? Are your users under-appreciating the blissful goodness that is the LOLcat? Feel like educating them a bit? Add or replace the following line in /etc/squid/squid.conf:

url_rewrite_program /bin/sed -u -r s!^([^[:space:]]*.(jp(e)?g|gif|png|tiff|bmp)).*$!!

Enterprising bofh’s could use a script to download the referred image, modify it, place it somewhere in /var/www/html and have the rewritten url point to the new bastardised image for extra credit, like this guy did.

It takes a bit more work, so let’s go over the steps:
Make sure you’ve got a webserver running on the same box as your proxy
Add/modify this line in /etc/squid/squid.conf

url_rewrite_program /etc/squid/

Now make /var/www/html writable by the squid user:

setfacl -m u:squid:rwx /var/www/html

And last but not least add this file as /etc/squid/ and make it executable:

while read URL
    SURL=$(echo ${URL} | cut -d" " -f1)
    echo ${SURL} | egrep -qi ".(jp(e)?g|gif|png|tiff|bmp|ico)$" &&
        (umask 002
         wget -q -O /tmp/${PIC} ${SURL}
         convert -quiet /tmp/${PIC} -flop /var/www/html/${PIC}.png &&;
        ) || echo $URL

The end result: