Skip to main content
Inspiring
May 20, 2021
Answered

New web applications on centos 7 server, calling other Application.cfc files from other directory

  • May 20, 2021
  • 1 reply
  • 634 views

Good morning,

 

      I have ran into a rather peculiar issue.  I have a CentOS 7 server with ColdFusion 2018 installed and configured.  Apache virtual directories are configures with correct directory structure to each web application document root via Plesk.  I'm going to use two web applications in this example, although I am experiencing the same issue with others.  

      I have one web application that when navigated to loads the correct Application.cfc file in it's directory root: r1gup.egtyctest.com.  The other web application, utgup2.egtyctest.com, is navigating to the r1gup.egtyctest.com Application.cfc file.  I placed a javascript alert on each Application.cfc files to display which Application.cfc file is being called and what the current hostname is being requested.  You can see the message when you navigate to either URL mentioned above.  FYI, these applications are in testing, and you will get a warning message when you navigate to these URL's to proceed.  

     The web root of each application on the server is below:

Working application: /var/www/vhosts/r1gup.egtyctest.com/httpdocs

Application using aboves Applicaiton.cfc file: /var/www/vhosts/utgup2.egtyctest.com/httpdocs

 

The other strange occurence i'm having with this is if i restart the coldfusion or apache server, the issue can reverse.  I will be able to navigate to the utgup2.egtyctest.com application and it will load the correct Application.cfc file and then r1gup.egtyctest.com will load utgup2.egtyctest.com Application.cfc file.  

 

After all my testing, I do not think this is Apache related.  The virtual hosts files for all the web applications have all the correct settings for the document roots, and if I default the first web page to be loaded with a simple index.html file, the correct page in the correct directory gets loaded.  This seems to be ColdFusion looking for the first available Application.cfc file, and loading that file, not respecting the web applications document root folder.  

 

Are there any other mappings I am missing to get the correct Application.cfc files loaded for each of my web applications?  Any insight will be greatly appreciated.

 

-Daniel

 

    This topic has been closed for replies.
    Correct answer DanielTheProgrammer

    Hi @DanielTheProgrammer ,

    The screenshots actually contradict what you originally said. The folder names r1rise.egtyctest.com and chgup.egtyctest.com were not in your original description.

     

    quote

    1st screenshot: I am being taken inside the r1rise.egtyctest.com folder...

     

    2nd screenshot: I am being taken inside the chgup.egtyctest.com folder ...

     


    By @DanielTheProgrammer

     

    No, not necessarily. Those folder names are artificial. They had been added by hand in the Javascript, as follows

     

    alert("In r1rise.egtyctest.com file, hostname: " + window.location.hostname);

    alert("Inside chgup.egtyctest.com, Inside hostname:" + window.location.hostname);

     

    Because the strings are added manually, they could be anything. They say nothing about the folder.

    The only value that is real is window.location.hostname. And it is, respectively, r1gup.egtyctest.com and utgup2.egtyctest.com, as expected.

     

    In short, there is no Application.cfc problem. What you have been seeing is just the result of a typing error in the Javascript's alert calls. If you want the Javascript to reflect what you observe, then change the alerts, respectively, to:

     

    alert("In r1gup.egtyctest.com file, hostname: " + window.location.hostname);

    alert("In utgup2.egtyctest.com file, hostname: " + window.location.hostname);

     


    Thank you BKBK for all the assistance with this issue, it has been resolved.  After spending time with Brian Bockholder and really reviewing the configuration of the server, we found the issue.  There is a checkbox in the Coldfusion Administrator page, under Server Settings -> Caching, "Cashe web server paths".  This checkbox was checked and was preventing my web applicaitons from loading their own web server paths.  After un-checking this box, and restarting the Coldfusion server, all my web applications would navigate to the correct paths.

     

    -Daniel

    1 reply

    BKBK
    Community Expert
    Community Expert
    May 22, 2021

    It is unclear to me whether:

     

    1) the Application.cfc files have distinct paths. That is, respectively,

     /var/www/vhosts/r1gup.egtyctest.com/httpdocs/Application.cfc 

     /var/www/vhosts/utgup2.egtyctest.com/httpdocs/Application.cfc 

     

    2) you gave each application a distinct name.

    You can do that using the following setting in the respective Application.cfc files:

    <cfset this.name="myR1gupApp"> <!--- in the r1gup Application.cfc file --->

    <cfset this.name="myUtgup2App"><!--- in the utgup2 Application.cfc file --->

    Inspiring
    May 24, 2021

    Hello BKBK,

     

         1) the Application.cfc file do have distinct paths just as you laid out: 

    /var/www/vhosts/r1gup.egtyctest.com/httpdocs/Application.cfc 

     /var/www/vhosts/utgup2.egtyctest.com/httpdocs/Application.cfc 

     

         2) All the applications do have their distinct name on the Application.cfc files

          <cfset this.name="r1gup.egtyctest.com">

          <cfset this.name="utgup2.egtyctest.com">

     

    Thanks,

     

    Daniel

    BKBK
    Community Expert
    Community Expert
    June 6, 2021

    Hi BKBK,

     

        Yes, I do have the javascript within the <cfunction name="onRequestStart"> block.   The screenshots confirm the issue I'm experiencing.  

    1st screenshot: I am being taken inside the r1rise.egtyctest.com folder and not the r1gup.egtyctest.com.

    2nd screenshot: I am being taken inside the chgup.egtyctest.com folder and not the utgup2.egtyctest.com.

     

    Thanks,

    Daniel


    Hi @DanielTheProgrammer ,

    The screenshots actually contradict what you originally said. The folder names r1rise.egtyctest.com and chgup.egtyctest.com were not in your original description.

     

    quote

    1st screenshot: I am being taken inside the r1rise.egtyctest.com folder...

     

    2nd screenshot: I am being taken inside the chgup.egtyctest.com folder ...

     


    By @DanielTheProgrammer

     

    No, not necessarily. Those folder names are artificial. They had been added by hand in the Javascript, as follows

     

    alert("In r1rise.egtyctest.com file, hostname: " + window.location.hostname);

    alert("Inside chgup.egtyctest.com, Inside hostname:" + window.location.hostname);

     

    Because the strings are added manually, they could be anything. They say nothing about the folder.

    The only value that is real is window.location.hostname. And it is, respectively, r1gup.egtyctest.com and utgup2.egtyctest.com, as expected.

     

    In short, there is no Application.cfc problem. What you have been seeing is just the result of a typing error in the Javascript's alert calls. If you want the Javascript to reflect what you observe, then change the alerts, respectively, to:

     

    alert("In r1gup.egtyctest.com file, hostname: " + window.location.hostname);

    alert("In utgup2.egtyctest.com file, hostname: " + window.location.hostname);