Cold Fusion Apache module problems
Posted: 8/3/2001 7:11:43 PM
By: Comfortably Anonymous
Times Read: 2,788
0 Dislikes: 0
Topic: Programming: Web Applications
(I don't see an actual Cold_Fusion topic here, ASP seemed the closest place to being on topic to me as it deals with server-side web application programming)

We are in the middle of migrating our web architecture from an old NT CF server to clustered CF servers on HP/UX front-ended by Apache running on Solaris. We have a HUGE (10000+ cfm files) amount of cfm content. We have to go through it all app by app to make sure that it functions properly in the new environment.

Since there are so many, we cannot just move them all at one time to the new hardware. Our plan (Same plan we have been sucessfully doing with our Java apps) was to have the new applications ran via the Cold Fusion module for Apache which then connects back to the clustered CF servers, and then use Apache's reverse proxy to connect to our old web server to continue keeping the non-migrated applications in service until they can be properly migrated.

However, the Cold Fusion module is being a pain - we cannot tell it which directories it should be active for, and which it should leave alone - therefore when it sees a .cfm file being requested, it grabs the request and passes it back to the clustered CF servers. However, it is also intercepting the requests for the .cfm files that have not been migrated, that we are passing off to the old servers via the reverse proxy. But, since these files do not yet exist in the new environment, we end up with the CF servers going 404 on us.

I need a way to either (1) instruct the Cold Fusion module to ignore .cfm requests for certain directories, or to (2) give mod_proxy and mod_rewrite priority over mod_coldfusion. I've played around with the Apache module loading order, trying mod_coldfusion either above or below the other modules in the AddModule/LoadModule directives of Apache's httpd.conf file with no results.

Does anyone have any ideas? I've spent most of this week with no luck and am about ready to start pulling my hair out. TIA!
Rating: (You must be logged in to vote)
Discussion View:
Replies:

Cold Fusion Apache module problems
Posted: 8/3/2001 7:11:43 PM
By: Comfortably Anonymous
Times Read: 2,788
0 Dislikes: 0
Topic: Programming: Web Applications
How to get mod_coldfusion to behave like any other Apache module:

First, edit the mod_coldfusion.c code shown below:

/*
* Check to see if this request has a coldfusion file type
*
* Valid file types are those which end in .cfm or .dbm
*/
int coldfusion_type_checker(request_rec *r)
{
char *ext;

/* ignore anything put GET and POST requests */
if ((r->method_number != M_GET) && (r->method_number != M_POST))
return DECLINED;

/* get file extention */
ext = strrchr(r->filename, '.');

/* if we can't find one, forget it */
if (ext == NULL)
return DECLINED;

/* skip over period*/
ext++;

if ((strcasecmp(ext, "cfm") == 0) || (strcasecmp(ext, "dbm") == 0))
{
r->handler = "type-coldfusion";
return OK;
}
else
{
return DECLINED;
}

}


Get rid of everything, just return DECLINED:

/*
* Check to see if this request has a coldfusion file type
*
* Valid file types are those which end in .cfm or .dbm
*/
int coldfusion_type_checker(request_rec *r)
{

return DECLINED;
}

No Apache module should be doing it's own inspection of filetypes, nor should these filetypes be hard coded. Not sure what the idea behind this was, absolutely backwards as to how any other Apache module works. I'd say 99% of all sys admins out there are going to end up wasting a lot of time on this one. Whether trying to reverse-proxy, or trying to serve up .cfml files instead, or trying to hide ColdFusion by parsing .html files - this strange module will kick them in the teeth.

Also, to speed things up even more (I haven't tested this, but assume it would work) replace coldfusion_type_checker with NULL in the following code so that Apache does not call the type_checker with each request:

module coldfusion_module = {
STANDARD_MODULE_STUFF,
NULL, /* initializer */
NULL, /* create per-directory config structure */
NULL, /* merge per-directory config structures */
NULL, /* create per-server config structure */
NULL, /* merge per-server config structures */
NULL, /* command table */
coldfusion_handlers, /* handlers */
NULL, /* translate_handler */
NULL, /* check_user_id */
NULL, /* check auth */
NULL, /* check access */
coldfusion_type_checker, /* type_checker */
NULL, /* pre-run fixups */
NULL, /* logger */
NULL /* header parser */
};

Now that you've got that done, you have to handle the module config in your httpd.conf file (Where it should be done like any other module):


AddType application/x-httpd-coldfusion .cfm
AddHandler type-coldfusion .cfm


- OR -


AddType application/x-httpd-coldfusion .cfm
AddHandler type-coldfusion .cfm


The directive can be any directory in your tree (You can also use the directive in place of the directive), you can use any file extension, blah blah.

Enjoy. I really wish I would not have had to waste 40 hours of my time to figure this out, this needs to be documented in the Unix/Apache documentation, and the module should be changed to behave just like the other modules out there. Perhaps this helps the lone developer who wishes a quick & dirty installation, but for the sysadmins at corporations with clustered app servers this is a major stumbling block. Also, there needs to be a way (via the Apache config file) to set where the module should look for the cfremote.ini file when setting up for clustered CF app servers, hard-coding it to /opt/coldfusion/cfremote.ini is a bad idea as well - the CF software should be installable to whereever the sysadmin/company wishes to install it.
Rating: (You must be logged in to vote)