Accessing Cluster Instances That Are Hidden Behind A Domain Name

Whenever I install ColdFusion Enterprise Edition, I install with the built-in web server - then I use wsconfig to connect my web server(s) to my CF instance(s). I then block traffic on those internal web server ports to the outside world. I set up CF this way because it:
  1. Makes it easy to make the CF Admin available without having to expose it to the public
  2. Removes complications that can arise when you need to use RDS, the server monitor, etc
  3. Allows me to access specific instances when I need to when I'm remoted into the machine
I recently had an interesting issue arise. In an environment I set-up (as described above) a client application was running off of a J2EE cluster of 4 instances. The application caches a lot of data in memory, and when certain events occur in the administrative application, those objects in memory need to be refreshed.
The first problem this poses is that from the instance that the user is currently logged in to, code needs to be executed on the other 3 instances so that they also refresh their memory cache. That's simple enough to achieve - just create a page or webservice that any one server can call on the others. You need to know what instance you're on so you know what the other 3 instances are, which also isn't very difficult (see a post of mine from a while ago at http://www.horwith.com/index.cfm?mode=entry&entry=80134845-E081-0478-475B6D83D8FAF903).
Unfortunately, the application itself is only accessible via very specific domain names... so I can't just send an HTTP or SOAP request to "127.0.0.1:830x" - all requests to this application must run through "www.x.com", which poses a problem when you need to access each instance specifically. A relatively simple solution is to send your HTTP request to the page/service via the domain name with a JSESSIONID cookie that you know belongs to the server instance you want to run the request. To get a valid session value for any one instance, I created a cfm file beneath the internal JRun web server on each instance, that just returns the session id. That file looks like:
<cfapplication name="dummy" sessionManagement="true">
<cfoutput>#session.sessionID#</cfoutput>
From the admin I request that file using cfhttp to get the value of the session in #cfhttp.filecontent#. Then I make my HTTP or SOAP requests - each time passing a cookie named JSESSIONID with the value I got when I asked the internal web server on thatinstance for a token value. One thing to note - you must pass the value as a cookie - passing it as a url value only works if cookies are disabled (i.e. if the cookie is there, the url variable is ignored).

Comments
This site is hosted by HostMySite and runs off of BlogCFC - thanks, Ray.