gog's info

<?php echo array_rand(array('web', 'dev', 'computers')); ?>

Archive for the ‘Linux’ Category

Set filenames with Nginx secure download module

without comments

When we switched from Lighttpd to Nginx a couple of months ago we were faced with an annoying problem.

Paying subscribers to our site have an option of downloading PDF files of the magazine. With Lighttpd we were using mod_secdownload to provide this functionality without exposing the files to the public. We compiled Nginx with the secure_download_module and it kinda worked.

Files were downloading as expected but the file names where all messed up. Download links where generated for each user and they looked something like this: /pdf/645.pdf/097ac16cb19ff6c163d6f813fdd44b4d/4b283bfa and the browser saved the file to the users hard drive with the file name of 4b283bfa. Since the file name didn’t have an extension it was impossible for the OS to know that is has to use a PDF reader to open the file.

Finally we managed to force the file name to the browser (download client) with a configuration directive that looks something like this:

    # PDF download
    location /pdf {
        secure_download on;
        secure_download_secret $request_addr;
        secure_download_path_mode file;
        root /path/to/dir/with/pdfs
 
        # Extract the name of the PDF
        if ($uri ~ "^/pdf/(.+\.pdf)$") {
            set $filename $1;
        }
        # Set appropriate headers
        add_header Content-Disposition "attachment; filename=$filename";
    }

And that’s all there is to it.

Written by Goran Jurić

March 31st, 2010 at 6:34 pm

Posted in Linux

Tagged with ,

Munin on Debian Lenny – Howto

without comments

I have been playing with an excellent monitoring tool Munin. Since I had some glitches while trying to install it on my server a have decided to update my Wiki a little bit and add a tutorial about setting up Munin on Debian Lenny. It is quite late and I do not feel like proofreading this entry right now so you will have to forgive me if I forgot something.

Written by Goran Jurić

September 28th, 2009 at 11:40 pm

Posted in Debian,Linux,Ubuntu

Tagged with , , , , ,

Removing require_once() calls from Zend Framework

with one comment

If you are using Zend_Loader to load your classes in Zend Framework, there is no need for all the require_once() calls that are littered all over ZF files.

Some acctually report big improvements in responsiveness of their applications and increase in number of transactions per second their hardware can handle because require_once() is quite an expensive operation, especially if the required file is already included prior to the call. Read the rest of this entry »

Written by Goran Jurić

October 16th, 2008 at 12:39 am

Dual display setup with Nvidia on Ubuntu 8.04

with 6 comments

Setting up multiple monitors under Linux can sometimes be quite a daunting task. TwinView, Xinerama, restricted drivers, editing configuration files, etc. doesn’t sound user friendly at all.

After you install Ubuntu and boot it the first time, you will get a notification in the tray asking you if you would like to install nVidia restricted drivers. They don’t get installed by default because the source code for this drivers isn’t open source. Since we don’t care about that, and just want the damn thing to work install the drivers. Read the rest of this entry »

Written by Goran Jurić

September 22nd, 2008 at 11:58 am

Posted in Linux,Ubuntu

Tagged with , , ,