A continuation of our look at the nginx web server. The appeal is less RAM usage, load balancing, and failover potential within our KVM virtual server environment.

So far we have nginx, php-fastcgi, apc, and perl-fastcgi set up in a 2 node load balancing configuration on Ubuntu Karmic serving HTTP and HTTPS. The rewrite rules and auth_pam are working nicely as well. Shared storage sitting on NFS. In the near future we will set up a heartbeat failover of the nginx proxy between the two nodes, to get both high availability and load balancing.

Our current configuration took a bit of testing to set up. The nginx package is a custom compiled from Jdub's Ubuntu PPA to include the auth_pam module. Following the custom package procedure described earlier will get you the custom package if needed.

In this post the configuration for perl-fastcgi to serve perl CGI scripts will be shared. Further configuration details will be posted in the future when more time is available and our own documentation takes shape.

Obviously Perl should be installed.

The FCGI.pm also needs to be in place, assuming CPAN is configured:

perl -MCPAN -e shell
cpan[1]> install FCGI

Our file /etc/nginx/perl-fastcgi is just a location entry for cgi scripts

    location /cgi-bin/ {
            alias /home/www;
            gzip off;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;

We installed a version of the fastcgi-wrapper.pl script found on the ruby forums


And the init script provided at linode library


At the bottom of a virtual server that will use perl cgi, place the following configuration option

include perl-fastcgi;

So a working virtual host configuration might look something like this

server {
        server_name  portal-bal.adams.edu;
        access_log  /home/www/logs/portal.access.log;
        error_log   /home/www/logs/portal.error.log;
        root /home/www/portal;
        location / {
                root /home/www/portal;
                index  index.html index.htm index.php;
                autoindex on;
            include php-fastcgi;
    include perl-fastcgi;

Next post will look at nginx reverse proxy caching.