Just one more thing, then I'm going to bed..

modjkl...@comcast.net wrote:
Thanks Andre,
I'd still be interested is there's a way to have mod_jk only check for traffic 
coming into mydomain.com for folder /mywebapp. I think the current solution 
checks all domains, such as mydomain2.com and mydomain3.com, etc., for a map to 
mydomain.com/mywebapp.

That is not really how it works, and it is easier to understand if you get the 
basics right.

a) a request comes to the server, and it looks like this :

GET /mywebapp HTTP/1.1
Host: host1.mydomain.com
(plus any number of additional lines)

b) the server looks for the "Host:" line, and picks up the hostname of the "virtual server" that this request is addressed to.
If it does not find such a Host: line, then this hostname is "empty" (or 
undefined)

c) Now the server compares this hostname, one by one with each of the <VirtualHost> sections' "ServerName" and "ServerAlias" directives.
If it finds an exact match, then it "selects" this <VirtualHost> to handle that 
request.
If it does not find a match, then it selects the first defined <VirtualHost> section to handle that request (that is a convention in Apache, that the first <VirtualHost> defined, from top to bottom of the httpd.conf, is the "default host"; in Tomcat, it is different).

d) Now the server switches its own configuration, to the one defined by the selected <VirtualHost> section. That is, the server "takes the personality" of that selected VirtualHost. (So in the case at hand, the Apache server now only "knows" the JkMount's applicable to this VirtualHost, and "forgets" all the others).

e) Next, Apache passes the request URL to mod_jk, and asks mod_jk it it wants to process this request. mod_jk looks into its URL-mapping table (the one for this VirtualHost) and decides if it wants to process this request or not. If yes, it tells Apache "yes, I want to process this request later", and Apache writes that down. If not, mod_jk tells Apache "no, I don't want this one". Then Apache will ask another module if it wants to process that request.

f) Apache does a number of other things to that request, and then passes it to the module that has indicated (see (e)) that it wanted to process this request. If that was mod_jk, then mod_jk gets the request, passes it to Tomcat, receives Tomcat's response, and returns this response to Apache.

g) Apache returns the response to the client, logs the request into the logs, 
cleans up etc..

h) Apache is ready to receive and process another request.

So, it is not mod_jk at all who decides if he processes requests for host1 or 
host2 etc..
That decision is taken by Apache, before it even passes the request URL to 
mod_jk.
When mod_jk receives the request URL (if it receives it), the VirtualHost has already been chosen, and mod_jk uses the URL-mapping table /of that VirtualHost/ to decide if it wants to pass this request to Tomcat or not.

Does that make it clearer why it is very important that the Adobe client specifies the correct Host: in his requests ?

That is also why in the JkMount directives, there is never a hostname 
specified, only URLs.

Is it clearer that way ?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to