Steven Erat's Blog
 
 
Viewing By Entry
 
 

TalkingTree  Can ColdFusion serve pages over a UNC path on Windows?

 

While there are disadvantages of that configuration, it can be done, and here's how to set it up. There's a variety of reasons why you might want to serve pages from a remote share, where the one I hear most often is so that ColdFusion can be run in distributed mode away from the webserver machine, where a firewall might exist between the two servers. In distributed mode rather than duplicating the application directory hierarchy on each machine so that IIS can serve static content from the "front end" and ColdFusion can serve dynamic content off the "back end", both from the same relative location under their local directory tree, you could instead use a UNC path so that ColdFusion reaches out to the webserver for the dynamic content. This allows all content to reside in one physical location while separating the application server from the webserver. I've also heard reports of wanting to use UNC paths for the document root so that a cluster of ColdFusion servers can read from a single source without worrying about synchronizing the content in multiple locations. Translating Webserver Paths to ColdFusion Paths - The webserver will form the "real path" to the requested resource by concatenating the path to the document root with the path to the requested file. So assuming the document root is at C:\wwwroot\ and the request is /foo/bar.cfm, when the request first passes over the JRun filter, the JRun connector will see C:\wwwroot\foo\bar.cfm and since the *.cfm is a pattern mapped to the ColdFusion servlet mapping, the connector will pass the request to ColdFusion and the webserver will forfeit handling of the request. The ColdFusion server will then attempt to resolve the path C:\wwwroot\foo\bar.cfm and read/compile/process the template. The webserver actually never even needs to have read access to the document root at all for dynamic/cfm content, and only ColdFusion will be responsible for resolving the path and reading the template source.

In order for ColdFusion to look in a UNC path for a template, it must have received a translated path that includes the UNC path, and that comes from the webserver. In order for the webserver to tell ColdFusion to look on a UNC path, the webserver Document Root must be configured as a UNC path. If you intend to have the content local to the webserver machine, then you can just set the Document Root as a UNC path having its own machine name. You could have all the content on a third machine, and then both IIS and ColdFusion will reach over the UNC path to the remote document root.

Access Control over UNC - In order for ColdFusion server to access dynamic content from a UNC path, it needs to run as an appropriate domain user account. From the Windows Services in the Control Panel, the ColdFusion server Service could be set to run as the domain user account instead of System, but notice in the Log On tab that only the System Account can interact with desktop. I found that when running ColdFusion as a domain account from a Windows Service that it could not access content over a UNC path (resulting in a ColdFusion 404 error), but when I ran ColdFusion from the commandline while logged on with the same user credentials that the templates could be resolved, read, and run. In my case, ColdFusion must not only run as a domain account but must also be able to interact with the desktop. For more information on this, see this article from Microsoft.

Since (in my experience) ColdFusion must be run from the command line rather than a Windows Service, the user that started ColdFusion must remain logged in, although the screen can be locked, but this means that ColdFusion won't automatically start when Windows is rebooted. There is a workaround for this by using the AutoAdminLogon feature of Windows while putting a shortcut to a batch file that starts ColdFusion in the Start > Programs > Startup menu; see this blog entry for more on that.

Separating IIS from ColdFusion and separating the content from IIS and ColdFusion will slow down performance since it just couldn't be as fast as when all components are on the same machine, but if you could run Gigabit Ethernet between the layers then you can certain gain some of that performance back.

I've tried using UNC paths as Virtual Directories in jrun-web.xml but was unsuccessful. Specifically I tried mapping / to a UNC path while escaping the path either as \\\\machinename\\sharename or //machinename/sharename, but neither option worked, although a mapped drive to that UNC path worked when the drive letter was used for the system path in the virtual directory. This solution might work for you if you only have one webserver connected to ColdFusion since a / mapping will override what the path that webserver tells ColdFusion, but if you have multiple website instances connected to one ColdFusion instance then a / mapping will route all requests to the same location.

Here's a few screen shots to help make sense out of this:

  • Configure webserver Document Root as UNC path, configure "Connect As". No need to run IIS Service as domain user if using "Connect As"
    Configure IIS for UNC path
  • Stop ColdFusion Service; Set the Service to Manual; ColdFusion can only access remote UNC path when allowed to "Interact with Desktop", but cannot configure Windows Service to run as domain account and interact with desktop since only "Local System" account can interact with desktop as configured on the Logon tab of the Service
    Stop ColdFusion Service
  • Log on as domain account user, run ColdFusion from commandline; ColdFusion runs as that user account and can interact with desktop
    Run ColdFusion from Commandline
  • Dump CGI scope to view CF_TEMPLATE_PATH and PATH_TRANSLATED
    Run test page to view cgi scope info

 


Comments

my experience is a little different. I have 4 windows 2003 servers each all accessing a clustered file share over a UNC path - i have a domain service account which all the CFMX installs runs as (via Services and not the command line). IIS is connected to the fileshare using the UNC path and the 'Connect As' option. No 404 messages here despite not having 'allow to interact with desktop' checked on the service properties.


Thanks for the info. While I've heard that some people can connect without having Interact with Desktop checked, I've only been successful with running on the commandline. Obviously, if you can connect when running as a Service, that's the better choice.


Steven,
Great post, as usual. We had this running for a few days, and we found that our increased network bandwidth was causing CF Server instability. That's probably because of the volume we operate at, but it would be nice if there were some way to decrease or eliminate bandwidth from the UNC host to the web server. We even had it running with trusted cache on. Is this normal? Now we're looking into automated content pushing solutions. thanks!


Ya we do this quite commonly. Our Development machine loads code off a Net Apps Filer; due to firewalls this is the only way our machines and the dev web server can see the same directory. But other benefits are that the net apps filer is RAID 5, and has a snapshotting backup system. When it comes time to deploy, we use the Deploy feature in Visual Source Safe to copy the code to a staging directory with a sync tool detects it and pushes local copies onto the production web servers.


2 things -

First - why do you run CF from the command line instead of a service? I've not found a reason to do this. Even with multiple instance setups.

Secondly - SANs are fantastic for getting all of the servers to see the same content. But it's not cheap, and in addition to the SAN you're going to need a traffic cop (such as IBM's SANFS)if you're running Winodws. It works, and you get INSANE disk performance which in turn, results in very high web server performance.

Otherwise, good article. I've seen several MM forum posts askinga bout this kind of thing.


Tom, as noted in the blog entry, some Windows OSes or configurations require a process to interact with the desktop in order to gain access to remote resources over the network, and that Microsoft article was the closest explanation I could find.

The Log On setting for Windows Services has a check box for "allow service to interact with desktop", but the setting is restricted to the System Account. If running as another user, that check box is not available. Since the System account can't access the network resources, the Service must be run as a user account from the Service, but that disables the option to interact with desktop. In my experience, on Windows XP and Windows 2000, ColdFusion could not access the remote network when run as a proper user from a Service.

To permit ColdFusion to interact with Desktop, I ran it from the commandline instead of a Service, and doing so allows it to interact with the desktop by definition and lets the process run as a specific user account. This was successful for me, and for others that I worked with it was successful for them.

Some people have commented that for them ColdFusion can access remote network resources on other Windows machines when running the Service as a user account even though the option to interact with desktop is disabled.

If you can run it as a Service and access remote resources, then great... this is the easier option, but if not, then try the commandline.


Hrm. That is really interesting. We've never had issues with CF accessing remote shares via UNC pathing (though I've never worked with CF on XP - just 2k and 2k3). However, we have CF configured to log in as a domain user - not a local user to the server. And we have the remote UNC share configured with the domain cf account permissions-wise.

The problem I see with your solution is in environments where multiple administrators need to access the server with their accounts. Or someone other than the primary administrator has to reboot the server for some reason. Running it on the command line means it won't come back until someone sits down and makes it happen. But, if it works, it works.

The only other thing I could think of is if maybe in a multi-instance environment you had issues calling different config scripts. But that's easy to deai with with the jrun service configurator.


Yep, that's right, I use my Macromedia domain account for testing, which is a local Administrator (its my primary workstation for several years now) and is in the remote Administrators group (on a lab machine I use all the time). I've reproduced the need for running from the commandline instead of a Service on other machines as well, and this has been the (Macromedia) solution for several customers attempting this.

Of course running as a service is better, and if anyone is really bumping into this it would be best for them to open a ticket with Microsoft for more about the limitations of Services or processes interacting with networked resources.


If you serve content over a UNC path, you might sometimes get a 404 File Not Found when a 'hiccup' occurs on the network, and ColdFusion will cache the 404 error. Here's a solution to workaround that:

http://www.talkingtree.com/blog/index.cfm/2006/2/2...


 

 

Calendar

 
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Search This Site

 
This is an exact search only

About This Site

 
I live west of Boston and used to work at Adobe with ColdFusion and Flex, specializing in Unix & Linux. I recently graduated from CDIA in Pro Digital Photography. Curious about my banner image?

More about me

Recent Entries

 
Christmas Eve Service makes F..
How To Filter by File Type in..
Perspective on ColdFusion's B..
Power Mac G5: The lights are ..
My Application to CDIABU in R..

Recent Comments

 
Posted By Yvonne:
Clear video taken! I was looking for such a video through Google & it led me to yours. Wanted to show to my students through a video clip, the whol ...

Posted By Andy Allan:
Fantastic work Steve.

Posted By charlie arehart:
Oh wow, awesome to hear that the relative quiet was an imposed one, and that the gag order has been lifted. Now I'm really excited to hear what may co ...

recently played

 
Snap Judgments
by WNYC, New York Public Radio
on On The Media
On The Media, WNYC, New York Public Radio

now playing, a plug-in for itunes

Categories

 
RSS Adobe (31)
RSS Bicycling (9)
RSS Blogging (37)
RSS Books (13)
RSS Breeze (12)
RSS CFMX Podcasts (10)
RSS ColdFusion (420)
RSS Computer Technology (50)
RSS Events (25)
RSS Flash (3)
RSS Flex (18)
RSS Gadgets (10)
RSS HiTech Industry (16)
RSS Java (25)
RSS Learning (57)
RSS Linux (70)
RSS Mac OS X (22)
RSS Macromedia (28)
RSS Meetup (34)
RSS New England (62)
RSS Odds & Ends (25)
RSS Outdoors (32)
RSS Personal (29)
RSS Photography (109)
RSS Photoshop (29)
RSS Podcasts (18)
RSS Rants (19)
RSS Restaurants (8)
RSS Science (34)
RSS Spain (16)
RSS Travel (42)
RSS Video (20)
RSS Webcam (3)
RSS Writing (10)

Blogs I Read

 
Scrum Sucks
Ben Forta
Ray Camden
Kinky Solutions
Gary Gilbert
Red Hat Blogs
O'Reilly Digital Media
O'Reilly Radar
John Nack
The Strobist
Scott Kelby
Matt Kloskowski
Joe McNally
Digital Photography School
Engadget
Science Blog

RSS

 


Add to Google
Add to My Yahoo!

Aggregated By

 


Consumed By Feed-Squirrel.com
Aggregated by ColdFusionBlogger.org

Credits and Stuff

 
BlogCFC - Free ColdFusion Powered Blog Software
CJM Group - ColdFusion Website Hosting


 
 
blog | photos | flickr | referers | webcam | stats | about | contact
 
Copyright © 2009 Steven Erat. All rights reserved.
This is a personal weblog. The opinions expressed here represent my own and not those of my employer