depicus

changing the digital world one bit at a time...

Blants (noun) the rants of a blogger

  1. Compress and Expire in Apache2

    February 15, 2016 by The Man

    This is so I can remember and copy/paste next time I need this. Add to your site.con

    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE image/jpg
    AddOutputFilterByType DEFLATE image/png
    AddOutputFilterByType DEFLATE image/gif
    AddOutputFilterByType DEFLATE image/jpeg
    </IfModule>
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 60 days"
    ExpiresByType image/png "access plus 60 days"
    ExpiresByType image/gif "access plus 60 days"
    ExpiresByType image/jpeg "access plus 60 days"
    ExpiresByType text/css "access plus 1 days"
    ExpiresByType image/x-icon "access plus 28 days"
    ExpiresByType application/pdf "access plus 28 days"
    ExpiresByType audio/x-wav "access plus 28 days"
    ExpiresByType audio/mpeg "access plus 28 days"
    ExpiresByType video/mpeg "access plus 28 days"
    ExpiresByType video/mp4 "access plus 28 days"
    ExpiresByType video/quicktime "access plus 28 days"
    ExpiresByType video/x-ms-wmv "access plus 28 days"
    ExpiresByType application/x-shockwave-flash "access 28 days"
    ExpiresByType text/javascript "access plus 7 days"
    ExpiresByType application/x-javascript "access plus 7 days"
    ExpiresByType application/javascript "access plus 7 days"
    </IfModule>


  2. Ubuntu find text in a folder recursively

    February 10, 2016 by The Man

    Very simple just grep it

    grep -r "WakeOnLanGui.zip" /var/www

    where WakeOnLanGui.zip is the text you want to find and /var/www is the folder and subfolders you want to search.

    Easy πŸ˜‰


  3. Clear out the Postfix queue

    December 7, 2015 by The Man

    If you find that your Postfix mail server is full of spam messages waiting to go out you can check the mail queue with

    mailq

    n.b. Postfix needs to be running for this to work but not if you need to purge the queue simple use

    postsuper -d ALL


  4. letsencrypt.org and XP – a bodge fix for chrome

    December 4, 2015 by The Man

    Ok as luck would have it the second site I set up letsenrypt.org‘s new certificates on the client was using Windows XP and Chrome and got this nasty error message when I redirected the http to https.

    Now I’m a firm believer of https everywhere – yes I know it doesn’t solve every problem but it helps. So the options were bleak according to a github issue but if you are using Apache it’s possible to bodge a solution so XP Chrome clients can still see your site.

    RewriteEngine on
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_USER_AGENT} !(Windows\ NT\ 5.1|Windows\ NT\ 5.2) [NC]
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}

    So what are we doing here.

    First we check to see if https is off – not sure this is really needed as we are putting this in our :80 .conf file.

    Then we check its NOT XP with the !

    And finally we redirect to the https address.

    Now we could get really clever and just check for Chrome on XP and I may work on that as I plan to use letsencrypt.org wherever I can πŸ™‚


  5. depicus is https now thanks to letsencrypt.org

    December 3, 2015 by The Man

    If you haven’t heard of letsencrypt.org they are “Let’s Encrypt is a new Certificate Authority: It’s free, automated, and open”

    Basically they will issue ssl certs for web sites free and in milliseconds, and here’s how.

    1. Get hold of the letsencrypt program

    git clone https://github.com/letsencrypt/letsencrypt
    cd letsencrypt
    ./letsencrypt-auto --help

    Then for me it was just a question of running

    ./letsencrypt-auto --apache -d depicus.com -d www.depicus.com

    And within seconds we are https – cool as <3


  6. Change Postfix port number

    March 31, 2015 by The Man

    Sometimes you want to send out but not have every spammer try and send you rubbish on port 25 so changing to a non standard port helps with automated spammers.

    First edit the config file

    sudo nano etc/postfix/master.cf

    and find the line

    smtp inet n – n – – smtpd

    and change to

    9876 inet n – n – – smtpd

    and then save and restart Postfix

    sudo service postfix restart

    then if you need to check simply grep

    netstat -tanp | grep 9876

    which should give you at least a line like this

    tcp 0 0 0.0.0.0:9966 0.0.0.0:* LISTEN