Here's an example to run Jifty app with nginx. It still has some problem. Please read to the bottom of this page before you try it.
Config: (Replace APP to your application root path)
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /opt/local/etc/nginx/mime.types;
default_type application/octet-stream;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
server {
listen 80;
server_name localhost;
root /APP/share/web/;
location ~ ^/static/ {
expires 10y;
}
location / {
if (-f $request_filename) {
break;
}
fastcgi_pass localhost:9000;
}
}
}
You need to manually start jifty fastcgi server with this command;
FCGI_SOCKET_PATH="localhost:9000" bin/jifty fastcgi
However, there is one important issue of this config. Jifty internally serves many javascript that does not live under APP/share/web/static/, You need to localized ALL those files in order to make it severable by nginx:
cp -rn /usr/local/lib/perl5/site_perl/5.8.8/auto/Jifty/web/static/* share/web/static
Usually this gets delegate to Jifty's fastcgi handler and do the right thing, but somehow it doesn't do so in Nginx. I guess this is fine because serving static files without going through perl is actually faster.