Enabling REST under Windows

Hello, I tried to get this example running on my Lucee Server:

https://www.youtube.com/watch?v=R_VnRawOhhc

It works fine at 127.0.0.1:8888/rest/metrics/system/os, but it doesn’t work at mywebsite.com/rest/metrics/system/os - instead I get a 404. I added the same REST mapping there as I did under 127.0.0.1:8888/lucee/admin/web.cfm?action=resources.rest.

In the first case the demo REST cfc is located at C:\lucee\tomcat\webapps\ROOT\restservices where the REST mapping points to, in the second case the REST cfc is located at [Webroot]\restservices where the REST mapping for this website is pointing to.

I assume I am missing some basic configuration step for getting this running as desired - but which one?

Configuration: Lucee 5.3.7.47 on Windows Server 2019 with Tomcat/IIS.

Regards,
RG

@RG2021 Yeah I too checked with this, localhost:8888/rest/metrices/test/os works fine and testbox.lucee.com/rest/metrices/test/os not working. But if we give url with port(testbox.lucee.com:8888/rest/metrices/test/os) means works fine in that webcontext too.
please check with this

Welcome @RG2021 to our community!!! If you installed Lucee using Lucee’s windows installer and boncode, make sure you have set up the IIS handler mapping for boncode right to catch all that REST URLs and pass them to Lucee for that site. Take a look at that link with the “Add handler mapping” section from Hostek.

Little note: Take care by adding them just by copy and paste, because there are some tags that are marked as closing tags.

UPDATE: Found a better solution here in this forum. Please see @dawesi s solution posted here.

Special thanks to @dawesi who posted the solution to his own issue and shared it with us all. That’s why it’s always important to share solutions, even if you come up with a solution on your own.

Hello cfmitrah, hello @andreas, thank you for the warm welcome and your help!

I added the handler mapping as described in dawesi’s post - now I am one step closer, but I still get this error message:

“no rest service for [/metrics] found”

Setting for localhost:8888/rest/metrices/test/os:
<rest><mapping default=“false” physical=“C:\iis-webroot-of-domain\restservices” virtual="/metrics"/></rest>

Setting for mywebsite.com/rest/metrics/system/os:
<rest><mapping default=“false” physical=“C:\lucee\tomcat\webapps\ROOT\restservices” virtual="/metrics"/></rest>

Both directories contain the system.cfc that consists of:

component restpath="/system" rest=“true” {
remote struct function getOS() httpmethod=“GET” restpath=“os” {
return server.os;
}
}

What am I still missing here? Thx again for your help!

Regards,
RG

Here is a guess:
Did you check if the rest virtual path mapping has been added to your mywebite.com web admin correctly within its own web administrator at http://mywebite.com:8888/lucee/admin/web.cfm ? If you’ve added the virtual path in the web admin of your localhost at http://localhost:8888/lucee/admin/web.cfm only, that doesn’t create it automatically for the context of mywebite.com This is what I would check.

Hello @andreas, yes, I added the rest mapping in the Lucee Web admin of my website under “Archives & Resources - Rest”. This results in the aforementioned addition to the lucee-web.xml.cfm for my website:

<rest><mapping default=“false” physical=“C:\iis-webroot-of-domain\restservices” virtual="/metrics"/></rest>

But now I found the reason for “no rest service for [/metrics] found” - I have to specify port 8888:

mydomainwhatever:8888/rest/metrics/system/os - works fine!

But of course I want to use port 80 for this - how can I solve this last problem?

Ok, then this is an IIS specific problem that is not passing the request correctly to tomcat. What is the error of IIS you are seing now, when you request http://mydomainwhatever/rest/metrics/system/os ? If you do the request from the server (not from a remote client) you should see a very specific detailed error, with a code status 404.x or similar (the “x” stands for a more specific detailed code).

I think the request is already being passed to tomcat, because the error I get (“no rest service for [/metrics] found”) sonds to come from Lucee/tomcat and not from IIS.

http://mydomain.com/REST/metrics/system/os gives a 404 from tomcat (because of the spelling REST instead of rest):

The requested resource [/REST/metrics] is not available

So we are already in the Lucee/tomcat world in both cases due to the handler mapping for rest/* in IIS, but need to get it done with port 80 instead of 8888.

If mydomainwhatever:8888/rest/metrics/system/os works fine, then Lucee is working just the way it has to work and the request is not being passed from IIS to Lucee as it should. I bet something is missimg in your IIS configuration, but I can‘t say what it is. Could you request a simple index.cfm through port 80 before setting up rest?

mydomainwhatever/index.cfm works fine via port 80, this site is in use for a long time. Only mydomainwhatever/rest/metrics/system/os I need to specify port 8888…