Support for VirtualDocumentRoot broken

40 views
Skip to first unread message

Tom Chiverton

unread,
May 6, 2019, 8:47:09 AM5/6/19
to mod_cfml
We have hosts defined like this :

<VirtualHost *:80>
    UseCanonicalName Off
    VirtualDocumentRoot /wwwroot/%2
    ServerName www.something.common.com
    ServerAlias www.*.common.com
</VirtualHost>

But mod_cfml logs :

...
[Mon May 06 12:33:13.237836 2019] [modcfml:notice] [pid 497] Incoming header [Host] => www.foo.common.com
...
[Mon May 06 12:33:13.237851 2019] [modcfml:notice] [pid 497] Incoming header [X-Tomcat-DocRoot] => /var/www/html

This means it is not correctly discovering the webroot "/wwwroot/foo" for the host, and Tomecat then gets the wrong path for the files.
For Apache hosts on the machine that use DocumentRoot everything seems OK.

So I think this is because it uses ap_document_root() which is marked as being a bad idea in [1] instead of something like the document_root property of the request [2]

I realise this might be a bit niche, and somewhat of a core change, but is there any chance of someone who knows more of the Apache internals having a look ?

Tom

Paul Klinkenberg

unread,
Jun 5, 2019, 7:40:42 AM6/5/19
to mod_...@googlegroups.com
Hi Tom,

Thanks for the complete info, and the research you've done.
The issue you described unfortunately can't be fixed.

It has to do with a combination of using mod_vhost_alias (for VirtualDocumentRoot) and mod_proxy.
Simply said, mod_proxy disables the use of mod_vhost_alias.
You can even see it in your Apache debug output: when you disable proxying for the given virtualHost, you will see the correct document-root at the "Request header [X-Tomcat-DocRoot]" log line. Assuming you have debugging turned on btw: LogLevel debug + LogHeaders true.

Both modules use the same "hook type" to execute their code, called ap_hook_translate_name.
Mod_proxy runs first, and when it finds a url it can proxy, it aborts the rest of the hook functions of this type. Meaning mod_vhost_alias is never called.

Sorry to see there is nothing we can do.

Kind regards,

Paul Klinkenberg

p.s. you don't want to know the amount of investigation I have done before I finally came to this conclusion 😭 I really thought it was fixable.

p.s. 2  The (logical) idea that the use of ap_document_root was the culprit, is not the case. The document_root value _is_ updated by the vhost_alias module, if it is run: https://github.com/apache/httpd/blob/trunk/modules/mappers/mod_vhost_alias.c#L379 (It did take 7 years before it was added to the code though: https://bz.apache.org/bugzilla/show_bug.cgi?id=26052)

The warning "don't use this" at the ap_document_root documentation is outdated since apache httpd 2.4 imho, no idea why they kept it there. The ap_document_root function since 2.4 first checks a request-specific document_root, before returning the default: https://github.com/apache/httpd/blob/trunk/server/core.c#L853 



--
You received this message because you are subscribed to the Google Groups "mod_cfml" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod_cfml+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tom Chiverton

unread,
Jun 7, 2019, 8:50:09 AM6/7/19
to mod_cfml
Hmm. So would an alternative be to use mod_ajp instead of mod_proxy ?

Tom
To unsubscribe from this group and stop receiving emails from it, send an email to mod_...@googlegroups.com.

Paul Klinkenberg

unread,
Jun 7, 2019, 9:27:58 AM6/7/19
to mod_...@googlegroups.com
Nope. Mod_proxy is the base module for proxying, and mod_proxy_ajp (and others) rely on the base functionality of mod_proxy.

Kind regards,

Paul Klinkenberg

------------


To unsubscribe from this group and stop receiving emails from it, send an email to mod_cfml+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod_cfml/1fffb03b-9074-4045-8c02-30655f0eec4c%40googlegroups.com.

Tom Chiverton

unread,
Jun 10, 2019, 11:02:13 AM6/10/19
to mod_cfml
Interesting. How does the Adobe ColdFusion connector manage to extract this information then ?

Tom
To unsubscribe from this group and stop receiving emails from it, send an email to mod_...@googlegroups.com.

Paul Klinkenberg

unread,
Jun 10, 2019, 12:11:16 PM6/10/19
to mod_...@googlegroups.com
Although we are getting a bit off-topic here (apples and oranges), I’ll answer.
Adobe ships it’s own mod_jk module. In the module, modifications have probably been made to fix this issue. Which would be pretty easy: only thing to do, is change the execution order of the “translate_name” hook in the jk/proxy module to Last.

Both because of update maintenance, and compatibility issues, the mod_cfml team probably won’t create the same.

Kind regards,

Paul Klinkenberg

------------


To unsubscribe from this group and stop receiving emails from it, send an email to mod_cfml+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod_cfml/1d923bf4-5cd0-45bd-a249-b127a3dc25bd%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages