Installation nginx - getrailo/railo GitHub Wiki

Railo/Nginx Installation on Windows 32-bit

Background Information

Installing Railo with nginx is a fairly straight forward process. Here we will cover a quick single host installation and set up the appropriate configuration files.

Download the Installation Files

Before we can begin the installation we need the installation files. Go to getrailo.org and grab the appropriate installation package. I will be using the Windows Railo Server 3.1.2.001 executable installer. You will also need to grab a copy of the latest Nginx zip from their download page.

First install Railo, I will be installing to C:\Railo with the default options. Once finished, Railo should now be listening for requests on port 8600.

Install and Configure the Applications

Now we 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"/>
</host>

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/nginx.pid;

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;
  #access_log  logs/host.access.log  main;
  location / {
   root   C:/Websites/default;
   index  index.cfm index.html index.htm;
  }
  # Main Railo proxy handler
  location ~ \.(cfm|cfml|cfc|jsp|cfr)(.*)$ {
   proxy_pass http://127.0.0.1:8888;
   proxy_redirect off;
   proxy_set_header Host $host;
   proxy_set_header X-Forwarded-Host $host;
   proxy_set_header X-Forwarded-Server $host;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-Real-IP $remote_addr;
  }
 }
}

To have the remote IP address show up correctly in Railo (assuming you are using Tomcat as your application server) we need to make one adjustment under the settings the server.xml file:

<Valve className="org.apache.catalina.valves.RemoteIpValve"  />

Adding the RemoteIPValve will correctly set the CGI.REMOTE_ADDR to the value passed in by the X-Real-IP header we pass while proxying the request back to Railo.

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.

Useful Resources

Nginx Wiki The main project wiki.

[nginx How-To](https://calomel.org/nginx.html Calomel.org) Really good reference for configuring nginx.

Nine-by-Six Server Straight forward Railo/nginx server installation.

Nginx Rewrite Rules Rewrite rules for nginx.

⚠️ **GitHub.com Fallback** ⚠️