Posterous theme by Cory Watilo

Nginx and Railo

I still have to do maintenance on my older CF sites. Luckily, I found the excellent Railo CF Server. I’ve also transitioned to using Nginx as my development and production web server…..mainly because of the ease of configuration…well, that and the speed and the reduced memory footprint compared to Apache.

In my development environment, I’ve symlinked the cfm source directory in the /railo-install-dir/webapps/ROOT path so I have something similar to this:

/railo-install-dir/webapps/ROOT/website-1/
/railo-install-dir/webapps/ROOT/website-2/

Then, in my nginx.conf file, I have an entry like this:

server {
  listen      80;
  server_name website-1.local;
  index             index.cfm index.html index.html;

  location ~ \.cfm$ {
    #proxy_pass can't have a uri so we use rewrite to change the uri to pass to Railo
    rewrite ^(.*)$ /website-1/$1;
    proxy_pass       http://127.0.0.1:8600;
    proxy_redirect   off;
    proxy_set_header Host                          $host;
    proxy_set_header X-Real-IP                     $remote_addr;
    proxy_set_header X-Forwarded_For               $proxy_add_x_forwarded_for;
    break;
  }
  location ~ / {      
    root             /home/myuser/cf_sites/public;
  }

}