Manually connecting Apache to a ColdFusion instance

I realised the other day when I was talking to a friend that my previous post on manually creating ColdFusion instances was kind of missing the last part of the process.

You've created a ColdFusion instance. You can start it up and you can access the admin. You've even made sure that proxy port is active, but now what? How do I manually hook up my shiny new instance to a web server? So I thought I'd write up this bit as well.

I haven't used IIS in a long time, so I'm not even going to contemplate how you would manually set that web server up with ColdFusion, but I can tell you how to connect Apache.

First of all if you've never hooked apache up to a ColdFusion instance you're going to need to sort out the jrun module that it needs to be able to pass through requests to JRun and your ColdFusion instance.

Tell apache to load the jrun module you need a line the main config that looks like this :

view plain print about
1LoadModule jrun_module /opt/jrun4/lib/wsconfig/1/mod_jrun22.so

The path to the mod_jrun22.so file can be anything you like, but this the location that wsconfig will most likely push the module to if you use that to configure your server. We're doing this by hand, so we need to find and extract the module so that we can use it with apache.

The connectors all live in a file called wsconfig.jar which lives under jrun4/lib folder. If you open the jar up in winrar or whatever your favourite archive application is you see a connectors folder. Inside of that are the following folders :

  • src
  • nsapi
  • isapi
  • installers
  • apache

The important folder to us is the apache folder which contains a bunch of folder for 32bit and 64bit versions of apache connectors for the following operating systems:

  • sparc-solaris
  • ppc-macosx
  • ppc-aix
  • pa_risc-hpux
  • intel-win
  • intel-macosx
  • intel-linux

Inside the appropriate OS folder for your processor type (32bit vs 64bit) there is a "prebuilt" folder. There are generally three versions of the jrun module; mod_jrun.so, mod_jrun20.so and mod_jrun22.so. mod_jrun.so is for apache 1.x, mod_jrun is for apache 2.0 and mod_jrun22.so is for apache 2.2. Extract the .so file relevant to you out to somewhere that apache can get access to it and add the LoadModule line above to your apache config with this path.

There's another line of config that I usually put with the LoadModule line;

view plain print about
1AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf
This just tells apache to send any requests for files ending in .jsp, .jws, .cfm, .cfml, .cfc, .cfr, .cfswf to JRun.

Apache on ubuntu has load and conf files for modules, so this goes in my jrun_mod.conf while the LoadModule goes in a jrun_mod.load file. On Windows I just lump the two config lines together in the httpd.conf file.

With this done all that is left is to connect your VirtualHost for the site needing ColdFusion to the proxy port of your ColdFusion instance. In your VirtualHost entry you will need to tell apache some JRunConfig to set the connection up, the most important one being:

view plain print about
1JRunConfig Bootstrap 127.0.0.1:51000

This tells apache to connect to the proxy port ColdFusion instance with a proxy port of 51000, so going back to my previous post I used the example of 51020 as the proxy port. To connect to this instance from apache we'd use "JRunConfig Bootstrap 127.0.0.1:51020". That on its own should be sufficient. However, there are usually a few other config items that the wsconfig would add for you :

view plain print about
1JRunConfig Verbose false
2JRunConfig Apialloc false
3JRunConfig Ssl false
4JRunConfig Ignoresuffixmap false
5JRunConfig Serverstore "C:/JRun4/lib/wsconfig/1/jrunserver.store"
6JRunConfig Bootstrap 127.0.0.1:51000
7#JRunConfig Errorurl <optionally redirect to this URL on errors>
8#JRunConfig ProxyRetryInterval <number of seconds to wait before trying to reconnect to unreachable clustered server>
9#JRunConfig ConnectTimeout 15
10#JRunConfig RecvTimeout 300
11#JRunConfig SendTimeout 15

Verbose is how much the JRun connector logs to the apache logs. Setting this to true will generate loads of information that can be useful for debugging. Apialloc false allows the connector to grab memory from the operating system rather than apache assigning it memory. Ssl allows you to create Secure Socket Layer connections to your ColdFusion instance if you've set them up. (look in the Jrun.xml file near the web and proxy connection information for the config for this) Ignoresuffixmap - I'm actually not entirely certain what this one does. I assume it makes the connector ignore the AddHandler and just send all requests to the JRun/ColdFusion instance. I could be wrong. Happy to be corrected. Serverstore is the location for of the jrunserver.store file that is used if you are clustering multiple instances.

The last four items I've thrown in for good measure and should be fairly obvious as to their meaning. The # at the front means that they are commented out. Generally I have Bootstrap, Verbose, Apialloc and Ssl enabled and all the rest removed or commented out.

The last thing to add to this; I tend not to do this, but if you want to you can wrap your JRunConfig in a check to make sure that the jrun_mod has been loaded. This would give you a config that looks like this :

view plain print about
1<IfModule mod_jrun.c>
2    JRunConfig Verbose false
3    JRunConfig Apialloc false
4    JRunConfig Ssl false
5    JRunConfig Ignoresuffixmap false
6    JRunConfig Bootstrap 127.0.0.1:51020     
7</IfModule>

Hope that helps someone out.

Also if anyone knows where the definitive list of JRunConfig options lives I'd love to know. I've hunted around to find out what the ones shown mean, but never found all the config items in one location with decent descriptions as to what they do.

TweetBacks
Comments
Thanks, very useful! I have CF hooked to Apache on my mac but never set it up on PC and have bees using IIS. Will give it a try
# Posted By Kal | 1/24/11 7:06 PM