A Regular Expression To Proxy Basic ColdFusion Requests

(Note: I’m cleaning up some old drafts which have been sitting around for awhile.)

A couple of years ago while setting-up a new J2EE server cluster using the Implementing Multitier Hardware Load Balancing with ColdFusion MX for J2EE or JRun article, I needed to setup a proxy filter for ColdFusion requests. Given that the application I was setting up used a context root of /, the proxy rule listed in that article would not work. Instead, thanks to my former co-worker Rod, I now have a regular expression which will redirect all basic requests for ColdFusion:

  1. ^((?:\S*.cfml?\S*)|\S*/(?:\?\S+)?)$

This regexp works for the following combinations:

  1. hello.cfm?hello=2
  2. hello/
  3. sadfa/
  4. dasd/?hello=231
  5. xo.cfm/hello
  6. hello/dookie.cfm
  7. dookie/hello.cfm?thisvar=dookie
  8. /

And the following requests are not proxied:

  1. /hello.html
  2. hello.html
  3. hello/hello.html

Obviously these are just basic test cases, but it should leave all CSS, image, JavaScript, etc. type requests to the webserver, and pass on everything else to the app servers. You would also need to change it to include direct requests for .cfc files if you’re doing anything like Flash Remoting, Web Services, etc directly to CFC’s.

This entry was posted in Languages, Tips, Hacks, & Tricks and tagged , , , , , , , . Bookmark the permalink.

0 Responses to "A Regular Expression To Proxy Basic ColdFusion Requests"

Leave a reply