2

I just starting to look into ColdBox and have just gone through the Quick Start (https://coldbox.ortusbooks.com/getting-started/getting-started-guide) and added #getSetting("APPNAME")# to the hello.index

Using CommandBox "start server" on my dev machine it starts it's internal server at port 55700 (which cannot get out of the firewall) and I get the expected output (see the first image) in which it is pulling the APPNAME from the .env file

Using my typical setup in which IIS servers everything on is served on either port 80 or 443) the APPNAME is coming from config/Coldbox.cfc (see 2nd image).

Even though the pages are all rendering via IIS (even if I do "server stop") in CommandBox, the variables do not seem to be correct.

Has anyone experienced this or know what I am doing wrong?

Code for that page in both screenshots

<cfoutput>
<h1>hello.index</h1>
#now()#
<div class="alert alert-danger">#getSetting("APPNAME")#</div>
<div class="alert alert-success">#getSetting("ENVIRONMENT")#</div>
<cfdump var="#application#" expand="false">
</cfoutput>

enter image description here enter image description here

Lance
  • 3,193
  • 2
  • 32
  • 49

2 Answers2

0

Make sure you are using the same web context: In the first image you are accessing 127.0.0.1, in the second a FQDN. That would work as same context only if you define one as alias at servlets host configuration level. Crosscheck the AccessLogs if possible webcontext are equally hit by your client.

AndreasRu
  • 1,053
  • 8
  • 14
  • Does Coldbox create the context somewhere other than the coldbox_app_root_path? You can see the paths in the screenshots above. I am seeing WEB-INF in that path and assume that both 127 and the TQDN are using that – Lance Feb 10 '20 at 14:01
  • You can check the web context path by logging into each web admins and look at the overview section at: Http://127.0.0.1:[port]/lucee/admin/web.cfm and at Http://cba.longthoughtsolutions.com:[port]/lucee/admin/web.cfm Are both web contexts paths equal? – AndreasRu Feb 10 '20 at 21:38
  • you hit it on the head. Even though the Webroot was the same there are 2 different contexts. Do you know if there is a way to "force" then 127 to use the other context? And for the future do I have to have CommandBox installed on the production server? I would like this site to work the same as all of the other CF sites on the server even though this one would be the only one that is Coldbox. – Lance Feb 11 '20 at 17:02
0

Using CommandBox "start server" on my dev machine it starts it's internal server at port 55700 (which cannot get out of the firewall)

As a matter of discussion, CommandBox will use any port you tell it. Whether por 55700 (the random port it decided to use in the absense of an explicit setting) is accessable outside your firewall is dependant on your firewall's settings.

and I get the expected output (see the first image) in which it is pulling the APPNAME from the .env file

ColdBox has no such built in function to pull the application name from a .env file. In fact, Coldbox doesn't pull ANYTHING from a .env file out of the box. Now there are various Coldbox and CommandBox modules or manual bits of code which may load settings from a .env file but you haven't mentioned using them nor have you showed your code.

Using my typical setup in which IIS servers everything on is served on either port 80 or 443)

Pardon our ignorance, but no one here knows what your typical setup is. Are you using IIS to proxy to CommandBox's web server via HTTP or AJP ports? Do you have some other installation of Lucee installed via another means?

the APPNAME is coming from config/Coldbox.cfc (see 2nd image).

The appname always comes from the ColdBox.cfc unless you've configured something explicitly to make it do otherwise. If you have something in place that you think should be loading the appname from elsewhere, please share that part of your code/setup.

Even though the pages are all rendering via IIS (even if I do "server stop") in CommandBox,

Again, how is your server configured? You mentioned stopping CommandBox. Do you have more than one CommandBox server running? Are you hitting the one you expect? If this is the site served via IIS, is it even tied to CommandBox?

the variables do not seem to be correct.

It's impossible to help you here as you haven't shared any of the code or configuration details that show how this setting is being defined in your code.

Has anyone experienced this or know what I am doing wrong?

I'm afraid there's not enough information here to know what you're doing, let alone what you're doing wrong.

And to address a couple of your questions in the comments...

And for the future do I have to have CommandBox installed on the production server?

Only if you want to use CommandBox to host the site. There is no correlation or requirement for a ColdBox site to be run on CommandBox. CommandBox is simply a CLI that makes it very easy to start and stop CF servers (among other things). Many people host production sites on CommandBox, but that is not a requirement at all.

I would like this site to work the same as all of the other CF sites on the server even though this one would be the only one that is Coldbox.

There's nothing special about a ColdBox site-- it works like any other ColdFusion app. I suspect you have confused yourself by thinking CommandBox is some sort of requirement. Many people use CommandBox for local development because it's fast and easy and then deploy on a "traditional" installation of ColdFusion or Lucee on production just out of familiarity.

Disclaimer: I'm the lead developer of CommandBox and a committer to ColdBox MVC.

Brad Wood
  • 3,863
  • 16
  • 23