[JBoss JIRA] (MODCLUSTER-463) UpperCase Alias never matches any context
by Michal Karm Babacek (JIRA)
[ https://issues.jboss.org/browse/MODCLUSTER-463?page=com.atlassian.jira.pl... ]
Michal Karm Babacek updated MODCLUSTER-463:
-------------------------------------------
Status: Resolved (was: Pull Request Sent)
Resolution: Done
> UpperCase Alias never matches any context
> -----------------------------------------
>
> Key: MODCLUSTER-463
> URL: https://issues.jboss.org/browse/MODCLUSTER-463
> Project: mod_cluster
> Issue Type: Bug
> Components: Native (httpd modules)
> Affects Versions: 1.2.11.Final, 1.3.1.Final
> Reporter: Michal Karm Babacek
> Assignee: Michal Karm Babacek
> Fix For: 1.3.3.Final, 1.2.13.Final
>
> Attachments: simplecontext-examples.zip
>
>
> h3. Problem
> h4. JBossWeb
> Regardless the upper/lower case of an Alias one configured in _JBossWeb (EAP 6.4.3, mod_cluster subsystem 1.2.11.Final)_, it has always been reported to Apache HTTP Server in lower case. For example, the following configuration:{code:xml}
> <subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" instance-id="workerXXX" native="false">
> <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
> <connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>
> <virtual-server name="default-host" enable-welcome-root="true">
> <alias name="localhost"/>
> <alias name="example.com"/>
> </virtual-server>
> <virtual-server name="web1" default-web-module="simplecontext-web1">
> <alias name="web1.rhel7GAx86-64"/>
> </virtual-server>
> <virtual-server name="web2" default-web-module="simplecontext-web2">
> <alias name="web2.rhel7GAx86-64"/>
> </virtual-server>
> </subsystem>
> {code}sends this message with aliases actually being reported in lower case: {{JVMRoute=workerXXX&Alias=web2%2Cweb2.rhel7gax86-64&Context=%2F}}. Having {{aliases}} stored in lower case on the Apache HTTP Server side enables both these URLs to work perfectly:{noformat}curl http://web2.rhel7GAx86-64:6666/
> curl http://web2.rhel7gax86-64:6666/{noformat}. The balancer configuration is just a simple [UseAlias 1|http://fpaste.org/251417/86985831/].
> h4. Undertow
> _Undertow (JBossWeb's successor in EAP 7.0.0.DR7, mod_cluster subsystem 1.3.1.Final)_ behaves differently; it reports verbatim what one sets as an alias, so with the following configuration:{code:xml}<subsystem xmlns="urn:jboss:domain:undertow:3.0" instance-id="workerXXX">
> <buffer-cache name="default"/>
> <server name="default-server">
> <ajp-listener name="ajp" socket-binding="ajp"/>
> <http-listener name="default" redirect-socket="https" socket-binding="http"/>
> <host name="default-host" alias="localhost">
> <location name="/" handler="welcome-content"/>
> <filter-ref name="server-header"/>
> <filter-ref name="x-powered-by-header"/>
> </host>
> <host name="web1" alias="web1.rhel7GAx86-64">
> <location name="/" handler="web1-content"/>
> <filter-ref name="server-header"/>
> <filter-ref name="x-powered-by-header"/>
> </host>
> <host name="web2" alias="web2.rhel7GAx86-64">
> <location name="/" handler="web2-content"/>
> <filter-ref name="server-header"/>
> <filter-ref name="x-powered-by-header"/>
> </host>
> </server>
> <servlet-container name="default">
> <jsp-config/>
> <websockets/>
> </servlet-container>
> <handlers>
> <file name="web1-content" path="${jboss.home.dir}/simplecontext-web1"/>
> <file name="web2-content" path="${jboss.home.dir}/simplecontext-web2"/>
> <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
> </handlers>
> <filters>
> <response-header name="server-header" header-value="WildFly/10" header-name="Server"/>
> <response-header name="x-powered-by-header" header-value="Undertow/1" header-name="X-Powered-By"/>
> </filters>
> </subsystem>{code}, the message reported to Apache HTTP Server actually is:{{JVMRoute=workerXXX&Alias=web2%2Cweb2.rhel7GAx86-64&Context=%2F}}. Due to the fact that aliases are being compared byte-by-byte for equality (because pumping of slash characters takes place) and the accessed domain is always in lower case and alias is stored as it was received, there is never match between these.
> The result is that while these work:{{http://web2:6666/}}, {{http://web1:6666/}}, one of the upper case containing ones work at all: {{http://web1.rhel7GAx86-64:6666}} and {{http://web2.rhel7gax86-64:6666/}} neither. By not working I actually mean they return the root of Apache HTTP Server Welcome page instead of correctly forwarding to one of the Application server's virtual host contexts.
> Last but not least, while EAP 6.4.3 with JBossWeb itself treats aliases as case-insensitive, EAP 7.0.0.DR7 with Undertow does not; i.e. {{web1.rhel7GAx86-64:8080/}} returns correctly web application content whereas {{web1.rhel7gax86-64:8080/}} returns EAP7 Welcome page.
> While the aforementioned is clearly a bug (or a weird feature :)) in Undertow, we must make the Apache HTTP Server code resilient to such behaviour.
> h3. Solution
> I suggest converting aliases to lower case in mod_manager on ENABLE-APP arrival. According to my preliminary tests, this approach works for both JBossWeb and Undertow equipped workers. I think it's cool to do that: [RFC 1035|https://tools.ietf.org/html/rfc1035#section-2.3.3].
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)