Mod_cfml woes with apache on windows

just trying to set up a couple of working directories with mod_cfml on windows with apache 2.4

two localhost virtualhosts, on ports 81 and 82

<Directory "c:/www/one/">
    Options Indexes FollowSymLinks
    DirectoryIndex index.cfm
    AllowOverride All
    Require all granted
</Directory>

Listen 81
<VirtualHost *:81>
    ServerName  zac-test-one
    DirectoryIndex index.cfm
    DocumentRoot  "C:/www/one/"
	
	<Proxy *>
		#Require host 127.0.0.1
	</Proxy>
	ProxyPreserveHost On
	ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2
</VirtualHost>


<Directory "c:/www/two/">
    Options Indexes FollowSymLinks
    DirectoryIndex index.cfm
    AllowOverride All
    Require all granted
</Directory>

Listen 82
<VirtualHost *:82>
    ServerName  zac-test-two
    DirectoryIndex index.cfm
    DocumentRoot  "C:/www/two/"
	
	<Proxy *>
		#Require host 127.0.0.1
	</Proxy>
	ProxyPreserveHost On
	ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2
</VirtualHost>

as you can see below, unique X-Tomcat-DocRoot / X-Webserver-Context combinations are generated

URI => /one.cfm, filename => proxy:ajp://localhost/one.cfm
Incoming header [Host] => localhost:81
Incoming header [Connection] => keep-alive
Incoming header [Cache-Control] => max-age=0
Incoming header [User-Agent] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3225.0 Safari/537.36
Incoming header [Upgrade-Insecure-Requests] => 1
Incoming header [Accept] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Incoming header [DNT] => 1
Incoming header [Accept-Encoding] => gzip, deflate, br
Incoming header [Accept-Language] => en-AU,en;q=0.9,en-US;q=0.8,de;q=0.7
Incoming header [X-Tomcat-DocRoot] => C:/www/one/
Incoming header [X-Webserver-Context] => zac-test-one-httpd-confl554
Handler Pattern Found => .cfm
Pattern Match TRUE: extension [.cfm] matches handler [.cfm]
Handler Pattern Found => .cfc
Handler Pattern Found => .cfml

URI => /two.cfm, filename => proxy:ajp://localhost/two.cfm
Incoming header [Host] => localhost:82
Incoming header [Connection] => keep-alive
Incoming header [Cache-Control] => max-age=0
Incoming header [User-Agent] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3225.0 Safari/537.36
Incoming header [Upgrade-Insecure-Requests] => 1
Incoming header [Accept] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Incoming header [DNT] => 1
Incoming header [Accept-Encoding] => gzip, deflate, br
Incoming header [Accept-Language] => en-AU,en;q=0.9,en-US;q=0.8,de;q=0.7
Incoming header [X-Tomcat-DocRoot] => C:/www/two/
Incoming header [X-Webserver-Context] => zac-test-two-httpd-confl575```

but which ever virtual host gets the first request, the second one just ends up serving from the first host's docroot?

have i missed something obvious?

Depending on which version of windows, a couple of different things could be happening.

<VirtualHost *:81>

Change that to

<VirtualHost 127.0.0.1>
<VirtualHost *:82>

Change that to

<VirtualHost 127.0.0.2>

Add additional IP addresses to your loopback adaptor

Add entries to the hosts file located in WINROOT\System32\Drivers\etc\

##
127.0.0.1 zac-test-one
127.0.0.2 zac-test-two
##

Restart Apache
Turn off windows firewall or what ever firewall you are using, for 127.0.0.1 & 127.0.0.2 or what ever adaptor(s) you are using to add the ip entries

I’d like to just use localhost on different ports due to

i’m running win10 pro x64

mod_cfml is correctly passing in the webroot, why is it being ignored?

Its the way you are attempting to access the sites via a virtual “name / port” and on Windows.

Windows 10 by default tries the internet first, then localhost cache, then the localhost, depending on version number / patch level you are running.

Try directly accessing the service(S) via the lucee jetty or tomcat instance.

I’ve done some playing around and I have found a workaround

adding a custom host header to the virtual host works and lucee creates a new context for each port
RequestHeader set Host "zac-test-two"

https://github.com/utdream/mod_cfml/issues/17

the problem is of course that cgi.server_name and cgi.http_host etc end up being set to “zac-test-two”

A solution could be possible to add support to lucee to automatically rewrite those variables based on an additional header, something like “X-Forwarded-Host”, or via a valve rewrite filter in tomcat?

ACF and Node developers can just simply run up a site on a different port, without having to mess around
with adding dns/host entries, adding ip addresses and getting ssl going

Lucee as it stands is a bit painful and that’s a bit of a barrier to adoption.