Installing Railo with Nginx web server on Windows

Update 3/3/2011: This information is now a little dated.  If you would like to see the updated content, cruise over the the Railo Wiki for the updated instructions.

Installing Railo and Nginx is fairly straight forward.  Here we will cover a quick and easy single host installation and setup the configuration files.

Before we can do that though, we need to get the installation files. Go to download section and select the version you want.  I will be using the Windows Railo Server executable installer.  You will also need to grab a copy of the latest Nginx zip from their download page.

First, run the executable and install, I will be using C:\Railo and installing with the default options.  Once finished, Railo show now be listening for requests on port 8600.  Now you need to edit the default host information in C:\Railo\conf\resin.conf.

    <!-- configures the default host, matching any host name -->
    <host id="" root-directory=".">
         - configures an explicit root web-app matching the
         - webapp's ROOT
      <web-app id="/" root-directory="C:/Websites/default"/>

Here we are changing the root-directory attribute in the default host block.  This directory will be the root directory of your server.

Once that is done you are ready to install Nginx.  I created C:\nginx and unzipped the files into this directory.  Next you need to edit C:\nginx\conf\nginx.conf.  Here is a sample nginx.conf I am using.

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/;

events {
 worker_connections  1024;

http {
 include       mime.types;
 default_type  application/octet-stream;

 #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
 #                  '$status $body_bytes_sent "$http_referer" '
 #                  '"$http_user_agent" "$http_x_forwarded_for"';

 #access_log  logs/access.log  main;

 ## Size Limits
  client_body_buffer_size     128K;
  client_header_buffer_size   128K;
  client_max_body_size          1M;
  large_client_header_buffers 1 1k;

 ## Timeouts
  client_body_timeout   60;
  client_header_timeout 60;
  expires               24h;
  keepalive_timeout     60 60;
  send_timeout          60;

 ## General Options
  ignore_invalid_headers   on;
  keepalive_requests      100;
  recursive_error_pages    on;
  sendfile                 on;
  server_name_in_redirect off;
  server_tokens           off;

 ## TCP options
  tcp_nodelay on;
  tcp_nopush  on;

 ## Compression
  gzip              on;
  gzip_buffers      16 8k;
  gzip_comp_level   6;
  gzip_http_version 1.0;
  gzip_min_length   0;
  gzip_types        text/plain text/css image/x-icon application/x-perl application/x-httpd-cgi;
  gzip_vary         on;

 server {
  listen       80;
  server_name  localhost;
  #charset koi8-r;
  #access_log  logs/host.access.log  main;
  location / {
   root   C:/Websites/default;
   index  index.cfm index.html index.htm;
   proxy_pass http://localhost: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;
   proxy_intercept_errors on;

   ## All other errors get the generic error page
   error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
    500 501 502 503 504 505 506 507 /error.html;
    location  /error.html {

There are a quite a few things going on here.  First we set a few basic parameters for requests such as the TCP options and general settings and turning on gzip compression.  Also the default server is configured so that it listens for requests on port 80.  The current server name is set to localhost and we set the root directory .  The root directory here will match the root directory you specified when installing Railo. Next, add index.cfm to the list of index files.

The most important part is setting our proxy up for the Railo server.  If you left all the options defaulted when installing Railo the port setting for proxy_pass should be correct already. Next set the http headers and error pages.  Save the configuration and start nginx by running C:\nginx\inginx.exe.

You should now be up and running.    Browsing to http://localhost/railo-context/admin/server.cfm should pull up the Railo Server Administrator.

My sample nginx.conf file is by no means production ready.  I have been playing around with configuration options so I will keep this updated.  The process is quick though, I downloaded all the apps and installed in under 15 minutes.

Here are some good resources if you need more information: Really good reference for configuring nginx. Straight forward installation. Rewrite rules for nginx.


One thought on “Installing Railo with Nginx web server on Windows

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s