Направление понял вроде. Получилось:
location ~* "/project/files/([0-9]+)/((.{2}).+)" {
root /var/www/project/webroot/files;
try_files /$1/$2 /$1/$3/$2 =404;
}
И все работает. Спасибо за помощь.
Posted at Nginx Forum: http://forum.nginx.org/read.php?21,49825,49868#msg-49868