Archive for the ‘Linux’ Category
Set filenames with Nginx secure download module
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.
Munin on Debian Lenny – Howto
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.
Removing require_once() calls from Zend Framework
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 »
Dual display setup with Nvidia on Ubuntu 8.04
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 »