Mappings from Lucee to webserver (IIS)

Hi all,

I am admittedly a hacker…but I love coding, and learning. I am frustrated with mappings…I seem unable to learn how those work, and I spend hours trying to figure them out. Here is a case in point.

I am planning to use IIS to host a rest api. I have built the rest api on localhost (my development environment). I created a script to complete the mapping in Lucee (api). After calling that script, the restAPI is created with the proper mapping in Lucee and works great, when I call the api at:

http://localhost:8080/rest/api/someCFCpath/someMethodpath?somevariable=somevalue

I decided to deploy to IIS, and to host the api on a subdomain, which I set up as a separate IIS website. I can run the script noted above, and the mapping is created in Lucee, but I am unable to access the rest service from that site, or from any other site (including the default site) in IIS. None of the following work:

(http://sub.myserver.com:8080/rest/api/someCFCpath/someMethodpath?somevariable=somevalue)
(http://www.myserver.com/rest/api/someCFCpath/someMethodpath?somevariable=somevalue)
(http://ipaddress:8080/rest/api/someCFCpath/someMethodpath?somevariable=somevalue)

How do I tell IIS that Lucee has a rest mapping? I tried adding a “virtual directory” in IIS to the new site with the same value (rest), but that didn’t work (note, my IIS hosts multiple sites). I did lots of googling, and tried this (step 6 in particular, with an IIS restart):

But no joy - I get an IIS 403 (don’t have access) or 404 (resource not found) error. I am sure this is very easy, but I just don’t understand how the web server (IIS in this case) and lucee “relate” to each other on mappings. I can’t seem to find a clear article or video that explains this.

Help appreciated…sorry for the mini-rant.

D

There’s a few bits of info missing to help here.

  • How are you connecting IIS to Lucee? Boncode? reverse proxy?
  • What kind of REST API is this? Using built in CF REST? ColdBox MVC? Homemade?
  • When you say “mapping”, what exactly do you mean? Servlet mapping? CF mapping? Virtual directory?
  • How are you running Lucee? CommandBox? Docker image? (if so, which one?) Standard Lucee installer?

Thanks - appreciate your response. Here you go:

  • Boncode (appears in the default list of IIS handlers for cfc, and cfm)

  • Uses built in CF Rest, so the “mapping” reported under “Rest” in lucee web administrator is “api” and to access that the path is “localhost:8080/rest/api/…” I configured this following in part instructions here (A simple app using Angular and Coldfusion REST API - YouTube) though I have also set the “api” manually in lucee, as set out here (RESTful Server - Part 1 - YouTube). Either way, the rest/api is running on my lucee/IIS environment (or at least is registered in lucee).

  • Perhaps my misunderstanding of what a “mapping” is IS the issue. I am not sure how to tell IIS that the “rest” service with the mapping above (in lucee) exists? To call the api, I would like to pass an URL string…how do I tell the web server (IIS) that “rest” is a service available from lucee using that URL string? Neither “rest” nor “api” are “real” or even “virtual” directories to windows/IIS, so an URL string with a subdomain that includes “/rest/api” is meaningless to IIS? How can I tell IIS that “/rest” exists, and that “/api” exists within “/rest” consistent with my configuration in Lucee?

  • standard lucee installer. Note, I have other CF applications running successfully on IIS

Got it. I’m not going to be much help if your issue lies in the built in REST. I hate it and it’s generally crap IMO. I’m biased, but I’d suggest you look into ColdBox REST in the future :slight_smile:

Ok, so right there I can tell what one of your issues probably is. Unless you’ve configured a wildcard mapping, Boncode is ONLY going to proxy requests ending with .cfm or .cfc to Lucee as you can see in your handler mappings. You need to create a mapping in IIS that tells it to send /rest/* requests to Lucee. I’m not sure if /rest/* is the correct path or not. You may need to do a * mapping, but you have to tell it NOT to check for the path to be real. That will get your requests flowing to Lucee. You can copy one of the existing boncode mappings to create the new one.

And finally, you need to check in your web.xml and see if the /rest servlet mapping is uncommented so Lucee’s REST servlet is grabbing the traffic. But this step comes after you’ve got IIS passing the traffic. In fact, I’d test hitting Lucee’s HTTP port directly first to see if it works, then add IIS/Boncode in the mix.

1 Like

Thanks - getting closer. I had added the new Boncode handler, and I can get the rest service working on the lucee port. I understand now I don’t need to create the mapping in IIS, other than through the handler. Just need to tweak the path in the handler…

Working…just used the * mapping for now…/rest/* and rest/* did not work on port 80 from IIS. Have to think about vulnerabilities with that…but good for now.

I’m not sure there’s an vulns per se to be worried about, but it does mean the default servlet inside your servlet container (tomcat) will be serving up all your static files.

This post in the forum seems to imply rest/* should work :thinking:
https://lucee.daemonite.io/t/lucee-rest-on-windows/6383/6
Make sure you went to request restrictions and unticked the “invoke handler only if request is mapped to” option.