I recently migrated my website away from Apache to nginx for performance reasons. The majority of the sites hosted on my server run WordPress, which was easy enough to get working easily under nginx’s rewrites. The one application I couldn’t get running properly out of the box was Subfolio, an application I use for uploading client galleries for proofing and download. I’m posting my configuration online in the hopes that it will help other Subfolio users wanting to use nginx.

    # Subfolio
    # Pass all .php files onto a php-fpm/php-fcgi server.
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/tmp/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }
    location = /login {
        rewrite ^(.*)$ /engine/index.php?kohana_uri=$uri last;
    }
    location = /logout {
        rewrite ^(.*)$ /engine/index.php?kohana_uri=$uri last;
    }
    location /hash {
        rewrite ^/hash/(.*)$ /engine/index.php?kohana_uri=$uri last;
    }
    location = /denied {
        rewrite ^(.*)$ /engine/index.php?kohana_uri=$uri last;
    }
    location = /notfound {
        rewrite ^(.*)$ /engine/index.php?kohana_uri=$uri last;
    }
    location ~ ^/engine/(config/settings|config/users|engine/application|engine/modules|engine/system) {
        return 403;
    }

    location / {
        index  /engine/index.php;

        if (-f $request_filename) {
            # translated into "if the request is an existing file, break (do nothing)"
            break;
        }
        if (-d $request_filename) {
            # translated into "if the request is an existing directory, break (do nothing)"
            break;
        }

        # the request is not an existing file or directory
        rewrite ^/(.+)$ /engine/index.php?path=$1 last;
    }

Hope it helps!