Is there a way to lookup Lucee server binding?

I’ve been messing around using Lucee with Docker and just realized an issue when running in a container. If I have code that tries to cfhttp to the local lucee server (e.g. scheduled task needs to hit a local url once per minute), it’s not obvious what address to use.

I can’t just connect to “http://localhost” because, within the container, the server is running on port 8888.
Same problem if I try setting it to “http://localhost:#CGI.server_port#”, because I’m accessing Lucee through an nginx reverse proxy, so CGI.server_port is also set to 80.

I could pass an environment variable to the docker container with the internal port address, but I’m just wondering if there’s an automatic variable available that contains the port that lucee/tomcat is actually listening to internally.

Thanks!

I’m a little confused how you’re wanting it to work. Are you trying to hit the local Lucee instance inside the container or are you trying to hit the external Nginx service and have it route in from there? You seemed to show both options, but then ruled them both out on account of each other.

It is a little confusing…

I’d like to hit the internal address so that the remote ip shows up as 127.0.0.1, but then I’d need to know the internal port.

This is mostly to satisfy the assumptions and retain compatibility with the existing code.

I’ve complicated it by the fact that, on my dev machine, I’m accessing the site through nginx using an /etc/hosts alias rather than localhost because I have several independent local site configs enabled.

Hm. So I guess the better general solution would be to make sure the Lucee container can access the same external name and port that client endpoints are using, i.e. using CGI.server_name, CGI.server_port, CGI.server_port_secure

To be clear, are you asking what to type here?

Because if this Lucee instance is running inside of Docker, then just put in the internal port and you’re done right? I don’t understand what the question is. You setup this docker image presumably, so you should know what port you’re using no??

Oh, I never realized there was an admin interface for that…nice!
With that UI, I could certainly enter an appropriate URL.

But before, I was referring to URLs that would need to be generated in the code (where I don’t necessarily know if I’m running in a docker container or not)

OnApplicationStart might start up a task to run every minute to hit a URL that processes scheduled events in the db (e.g. start/stop stream recorders on a Wowza server). Currently, it’s handled by Windows Task Scheduler, but I kinda hate it and wanted to move those processes into Lucee’s task scheduler.

Hm…looking at the admin interface now… it seems like I can’t actually use it to create a task that repeats once per minute. The options are once, daily, weekly, months …and “every…”, which appears to mean “hourly”

Oh… if you set it to “every…” and then go back in and edit the task, it does let you change the interval value…just not on creation.

There’s a checkbox to “Translate relative URLs into absolute” …does that mean I could just enter a relative URL and forget about the whole host and port altogether?

edit: Nope.

you can get info about the current request using

getPageContext().getHttpServletRequest()

Thanks, that’s exactly what I was looking for:

var req = getPageContext().getHttpServletRequest();
dump(req.getLocalPort());
1 Like