Mod_cfml isn't triggering on the first request

I’m running apache 2.4.46, and rather than yet another commandbox instance, I’m now just running lucee docs via a virtualhost with mod_cfml.

If i restart Lucee and open http://docs.localhost/ I get the default welcome to lucee page, coz mod_cfml hasn’t kicked in and told tomcat how to handle this host.

If I then open http://docs.localhost/index.cfm, then mod_cfml kicks in and tomcat gets educated by mod_cfml and then everything subsequently works, including just good old http://docs.localhost/

the docs localserver all runs thru application.cfc onRequestStart and everything, is served via lucee (js,images,css)

<VirtualHost *:80>
    ServerName  docs.localhost
    DocumentRoot  "C:/work/lucee-docs/server"
	ErrorLog "logs/docs-error.log"
	CustomLog "logs/docs-access.log" common
    DirectoryIndex index.cfm
    RewriteEngine on
    RewriteRule ^(.*)(/.*)?$ ajp://{http_host}:8009$1$2 [P]

any suggestions?

edit the /winroot/system32/drivers/etc/hosts

typically c:\windows\system32\drives\etc\hosts

add docs.localhost

save the file and reboot

thanks, but I’m pretty sure that’s not my problem?

pretty sure the problem is mod_cfml only kicking in when it encounters a request with a file extension of .cfm or .cfc

in your main configuration or vhost add

LoadModule modcfml_module modules/
CFMLHandlers “.cfm .cfc .cfml”
LogHeaders false
LogHandlers false
LogAliases false
VDirHeader false

thanks, but I think I made it pretty clear in my original post, that it’s all configured and working

I’d have guessed that you haven’t added any DirectoryIndex index.cfm in your virtual host configuration, but that’s not the case. I’ll also take a look at this and take the chance installing apache on Windows. Never did that. As soon as I get home I’ll check it.

I made it as unclear as can be that Windows 10 name resolution is absolutely crap.

Having DNS servers configured in a client’s TCP/IP configuration, but the server is not available to the client usually causes this. Because the TCP/IP protocol assumes an unreliable network, a client will repeatedly attempt to connect to a DNS server before abandoning the attempted query. The client will then attempt to query a second DNS server if one is configured and take the same time to fail. Only then will the client step through to NetBIOS name resolution as described above.

There are three ways to approach this issue.

If the host name is correctly entered in a host file, it will be resolved before the client attempts to query DNS. This solution works well if DNS servers are temporarily unreachable and there is a small number of host names that need to be resolved . Manually configuring Hosts files for numerous clients may be prohibitive.

yeah, it totally sucks that browsers support *.localhost and windows doesn’t OOTB

but it’s working nicely for me

1 Like

I think the problem is that mod_cfml is triggering on the uri, as opposed to the filename? @paul_f

The exact same thing happens with mod_cfml and Taffy - our production instances all had mod_cfml removed and a health check made to poll ‘/index.cfm’ to work around this.

For our dev Docker images, it’s just something we live with; the browser remembers the URL so it’s not much extra effort.

I’m kinda wondering if all the checks to avoid adding a few headers in mod_cfml is more expensive than just adding the headers…

checking the filename extension is cheaper that checking the uri with SES urls

it’s all c, so honestly, the performance difference will be a rounding error

“browsers support *.localhost”

In what way ? We’re still banging lines into hosts files to support local development …

@thefalken Browsers will basically resolve any foobar.localhost domain to 127.0.01. I put some changes in the last version of CommandBox to “support” this. basically by detecting any time a user uses an xxx.localhost domain that isn’t in the hosts file and I swap it out for just localhost in the background. browsers will resolve the domain, but the rest of your PC’s networking stack will refuse to recognize it (including java) without a hosts file. (which is why I just swap it out for you so the server actually binds on localhost but we still open the browser URLs to your subdomain.

That being said, I still use the hostupdater module just so I can bind the same port to more than one local server.

1 Like

I had no idea this was a thing ! When did this happen ?

Our dev tooling bundles Lucee (etc) inside Docker, and set’s it up so (local Docker mapping)/foo is available as https://foo.localdomain

Sounds like I just need to add the same thing for foo.localhost and our hosts file editing days are over !

I think it might have always been that way, I’ve always found it a bit quirky, finally bothered to investigate

(i meant the mod_cfml being triggered on uri rather than resolved filename)