Manually Configuring IIS with Lucee

OS: Windows Server 2012 Standard
Java Version: 11.0.15 (Eclipse Adoptium) 64bit
Tomcat Version: Apache Tomcat/9.0.62
Lucee Version: 5.3.9.160

  • I have a collections of intranet applications running on CF10 on IIS.

  • I would like to switch to Lucee instead of upgrading the ACF, but I am having some trouble getting the existing sites configured with Lucee.

  • I was able to install an ACF2021 trial and configure the sites to run on that instead of ACF10, but configuring the same sites to run on Lucee is eluding me.

  • I removed all of the ISAPI filters, virtual directories and Handler Mappings related to ACF installs for one site.

  • I installed Lucee without the IIS connector
    (I tried with the connectors, but Lucee wasn’t working and had issues getting the other sites back to ACF, so I thought I should try manually configuring one site to work with Lucee instead. I have one public facing site I need to get upgraded in the next few days to fix security issues. I either have to get Lucee working or I have to pay for the ACF license because my trial is about to run out)

  • I created the BIN folder in the website root and copied BonCodeAJP13.dll, BonCodeIIS.dll and BonCodeAJP13.settings

  • I added these handlers to the web.config:

        <handlers>
            <remove name="BonCode-Tomcat-CFM-Handler" />
            <remove name="BonCode-Tomcat-CFC-Handler" />
            <add name="BonCode-Tomcat-CFM-Handler" path="*.cfm" verb="*" type="BonCodeIIS.BonCodeCallHandler" modules="ManagedPipelineHandler" resourceType="File" requireAccess="Script" allowPathInfo="false" preCondition="integratedMode" />
            <add name="BonCode-Tomcat-CFC-Handler" path="*.cfc" verb="*" type="BonCodeIIS.BonCodeCallHandler" modules="ManagedPipelineHandler" resourceType="File" requireAccess="Script" allowPathInfo="false" preCondition="integratedMode" />
        </handlers>
  • I added this to the BonCodeAJP13.settings with the matching secret from server.xml (this fixed one error caused by refusing the connection)
    <RequestSecret>secretFromServer.xml</RequestSecret>

I was mainly following this as guidance:

Where I’m getting stuck is that each time I try to add the host entry in the server.xml file and refresh the site, I get this error and Tomcat shuts down:

Generic Connector Communication Error:
Please check and adjust your setup:
Ensure that Tomcat is running on given host and port.
If this is a timeout error consider adjusting IIS timeout by changing executionTimeout attribute in web.config (see manual). [2022-08-24 16:35:00 ]
Connection between Tomcat and IIS experienced error. If you restarted Tomcat this is expected. (1) at BonCodeAJP13.BonCodeAJP13ServerConnection.ConnectionError()
at BonCodeAJP13.BonCodeAJP13ServerConnection.p_CreateConnection(BonCodeAJP13PacketCollection packetsToSend)
at BonCodeIIS.BonCodeCallHandler.ProcessRequest(HttpContext context)

When I remove the host entry I get the default Lucee page instead of the site I’m trying to configure:
Warning, if you can see this message, your webserver webroot is not mapped to [E:\Programs\lucee\tomcat\webapps\ROOT].
This means Lucee is only configured to handle .cfm and .cfc and other files like css, js and images won’t load properly

This is the HOST entry I’m adding:

<Host name="intranetstage.nadap.org" appBase="webapps">
    <Context path="" docBase="E:\webs\nadapintranet\www" />
    <Alias>intranetstage.nadap.org</Alias>
</Host>

FYI, the code for all of my applications runs from a separate E drive and not from within the IIS wwwroot on the C OS drive. I’ve always kept everything application related on one drive and the OS stuff separate. It makes migrating to a new machine easier.

I’ve been working on this for a few days and I’m running out of time and going in circles. I feel like I’m close, but I’m just missing something. I would love to come over to Lucee world so any help is greatly appreciated.

For the heck of it, I copied the whole site into the root folder and updated the host entry and iis configuration to point to that folder. Now it seems to be executing the index.cfm file, but I’m getting this error:

E:\Programs\lucee\tomcat\webapps\ROOT\nadapintranet\www\index.cfm: line 25
23:
24: <cfparam Name = "Action" Default = "Home" >
25: <cfif Session.UserID EQ "0" or ucase(Action) eq "LOGIN" >

Progress I guess but not ideal. In any case,
that Session.UserID variable is set in the application.cfc that up one directory in the nadapintranet folder and not in the www folder. It seems like it’s not picking up the application.cfc?

I checked the Application listener settings and it’s set to “Current to root” which is how I expected it to work.

FYI, I had this same problem when I installed Lucee with the IIS connectors. I tried moving the application.cfc into the same folder as the index.cfm file. I tried including it in the index.cfm file and the page came back blank and the undoing it didn’t fix it and I had to remove everything and reconfigure it to ACF to get it running again and start over.

What problem did you have exactly? Any detailed errors to show us?

It wasn’t picking up the application.cfc file.

I also only need to configure the one public facing site to run on Lucee for now until I can test and migrate all of the applications over to Lucee so I don’t want to switch everything over at once. I’m about to go on vacation to get married and my ACF trial expires in 3 days so I’m kind of freaking out now.

So, other .cfm files (without an application.cfc) were working normally?

Yes, it’s executing the index.cfm file. I just included the application.cfc file in the index and called the onRequestStart function and that part seems to be working, but now the cgi.remote_user variable is an empty string. This site uses windows authentication so I need that var to log the user in.

Ahhh ok, so that everything is working, but the cgi.remote_user is not being passed from IIS to Tomcat.

That seems to be the issue now. Of course I’m not sure why it’s not seeing the application file without having to include it, but I can work on that later.

This CGI var in Lucee comes from the servlet’s request context. It’s possible to get Tomcat to grab the remote user from IIS when using AJP, see tomcatAuthentication, and tomcatAuthorization here:
https://tomcat.apache.org/tomcat-9.0-doc/config/ajp.html#Standard_Implementations
However, I have no idea if Boncode sends these request attributes or not. You can find out by dumping them out to see what’s there.

dump( getPageContext().getRequest().getAttributeNames() )

If you can’t get that to work, you’d probably need to set up a rewrite rule in IIS to send it in an HTTP header you can read in Lucee.

1 Like

I was able to fix it by setting tomcatAuthentication= false within the AJP Connector section in the server.xml in Tomcat. Thanks!

2 Likes

Still, regarding your Application.cfc not being picked up: Have you tried an empty webroot, creating the index.cfm and an application.cfc (just these two files) with a simple one liner code to see if your Application.cfc is really being ignored? e.g. by dumping the cgi scope?

I’ll try that. For now I just copied the entire onRequestStart function into the index.cfm file and executed it at the top. It’s dirty, but it’s working and I’m under the gun. I will try your suggestion when I have more time.

I didn’t see in your previous posts - is this on the same server?
Or is Lucee on a separate server to the ACF instance?

They are on the same server. I did try creating a test site with just an index and application file, but I didn’t have any luck getting it to pick up the application file. I even renamed the default application in the Webroot to make sure it wasn’t picking that one up. Then I tried changing everything back and updating the default application and index file to see if I could pass any variable from the application to the index and it didn’t work. Should I have restarted tomcat in between these changes? Would that have made a difference?

I got the application I needed to get migrated by COB Friday moved before I went on vacation so I’m grateful for Lucee. It’s running fine for now. Since the whole app runs through the index.cfm file I was able to include everything I needed from the application file in that for now. I’ll do some more testing when I get back to town.

Wait, just for my understanding… Please excuse my persistance, I just need to understand it. Are you saying that certain variables you are setting in your Application.cfc aren’t being passed properly to your index.cfm file? Or is it that your Application.cfc isn’t really running? Now I’m understanding that variables aren’t being passed to your .cfm templates.

So what happens if you run an Application.cfc like this:

component displayname="Application" output="false" hint="Handle the application" {
dump(cgi);
abort;
}

With an empty index.cfm? Does it dump the cgi scope or not?

No worries, I would love to figure it out. It doesn’t seem like the application files are getting picked up at all. I was trying to pass a variable from application to index to test if the application was being picked up. I will try that when I get back next week.