View Light

RE: Cold Fusion Apache module problems

Parent Message
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)
Reply