Web.cfc : CGI variables wrong

I’m trying to hit a Taffy URL on the current host at start up, earlier than Application.cfc’s onApplicationStart() - before the first request arrives, ideally

If I dump CGI from inside my /Web.cfc onWebStart method, CGI.SERVER_NAME is always “localhost”.

Our sites are added to Tomcat’s conf/server.xml as <Host ... blocks, and getPageContext().getServletContext().getVirtualServerName() contains the name given there (prefixed with “Catalina/”).

Am I doing something wrong and/or impossible ?
Is there some way of getting the actual host name, as getVirtualServerName() really cautions against using it this way : ServletContext (Java(TM) EE 7 Specification APIs)

Tom, the CGI scope variables are affected by whatever web server you use (if any, in front of Lucee or cf). You’ve not clarified if you use one (apache, iis, nginx, etc or even undertow as implemented within Commandbox).

If you do, then the host name passed into that web server WOULD normally be passed on into Lucee (or cf) via the CGI scope, but that could vary depending on how you may have configured the connection to Lucee in that web server.

On some configurations, the host name is passed into Lucee (or cf) as a header, and as you may already know you can see such headers using the cfml function gethttprequestdata() and its headers struct. Try dumping that and let us know if it helps.

If not, do let us know more about what may be fronting lucee, if anything at all. (I realize you could be calling the built-in tomcat web server, used to serve the lucee admin by default. And if that’s just for testing but you’d ultimately deploy another way, test calling your code that way.)

Thanks.

Let me try and add that detail; We’re basically using a setup the same as the Lucee Docker images - Nginx in front of the Tomcat, with name based virtual hosting in Nginx, and multiple Host tags in Tomcat with different webroot / docBase

Based on your suggestion I’ve dumped getHttpRequestData() from Web.cfc, and that’s returning
{""content"":"""",""headers"":{""AMF-Forward"":""true""},""protocol"":""HTTP/1.1"",""method"":""GET""} " so maybe the ‘synthetic’ request somewhere inside Lucee that calls Web.cfc onServerStart() is lacking enough details to pass it in or something ?