tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From modjkl...@comcast.net
Subject Re: mod_jk doesn't map to software-generated web address, but maps to this address when I enter it into browser
Date Thu, 16 Feb 2012 23:38:16 GMT
Thanks so much Andre for taking the time to help me understand this. It's VERY helpful! I've
attached the section of httpd.conf below related to virtual hosts. I think I'm starting to
get the picture now. 

Whatever I input into Adobe's software, I ALWAYS see in the mod_jk.log file the hostname:
host3.mydomain.com. Based on your description below, Apache webserver would select the first
virtual host associated with that name. In this case, the first VirtualHost section below
would not match (since xx.xxx.xxx.196 does not match host3.mydomain.com). But I'm guessing
the 2nd VirtualHost section below DOES match (since I interpret * to match anything). 

However, I was intending the 3rd VirtualHost section below (e.g. <VirtualHost xx.xxx.xxx.196:80>
to match the hostname used by Adobe (this where I originally had the JkMounts located) since
it had the alias host3.mydomain.com. But you're right, Apache would have assigned it to the
other VirtualHost before it even reached this point. This should explain why the Global JkMounts
worked as they did.

One question: where we define NameVirtualHost below, is it better to use *:80 instead of xx.xxx.xxx.196:80?
The server has 2 IP addresses associated with it, although I *think* only 1 is used in practice.


--------snippet from httpd.conf showing virtual-host related items---------
PidFile logs/httpd.pid
LockFile logs/accept.lock
Listen 0.0.0.0:80
User nobody
Group nobody
ExtendedStatus On
ServerAdmin webmaster@webcompany.net
ServerName host3.mydomain.com
LogLevel warn
Timeout 300
ServerSignature On

NameVirtualHost xx.xxx.xxx.196:80
NameVirtualHost *

<VirtualHost xx.xxx.xxx.196:80>
    ServerName host3.mydomain.com
    DocumentRoot /usr/local/apache/htdocs
    ServerAdmin webmaster@webcompany.net
    <IfModule mod_suphp.c>
        suPHP_UserGroup nobody nobody
    </IfModule>
</VirtualHost>

# Default vhost for unbound IPs

<VirtualHost *>
    ServerName host3.mydomain.com
    DocumentRoot /usr/local/apache/htdocs
    ServerAdmin webmaster@webcompany.net
    <IfModule mod_suphp.c>
        suPHP_UserGroup nobody nobody
    </IfModule>
</VirtualHost>

<VirtualHost xx.xxx.xxx.196:80>
    ServerName mydomain.com
    ServerAlias www.mydomain.com host3.mydomain.com
    DocumentRoot /home/gkk/public_html
    ServerAdmin webmaster@webcompany.net
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/mydomain.com combined
    CustomLog /usr/local/apache/domlogs/mydomain-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User gkk # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup gkk gkk
    </IfModule>
    <IfModule concurrent_php.c>
        php4_admin_value open_basedir "/home/gkk:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp

        php5_admin_value open_basedir "/home/gkk:/usr/lib/php:/usr/local/lib/php:/tmp"
    </IfModule>
    <IfModule !concurrent_php.c>
        <IfModule mod_php4.c>
            php_admin_value open_basedir "/home/gkk:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/

mp"
        </IfModule>
        <IfModule mod_php5.c>
            php_admin_value open_basedir "/home/gkk:/usr/lib/php:/usr/local/lib/php:/tmp"
        </IfModule>
        <IfModule sapi_apache2.c>
            php_admin_value open_basedir "/home/gkk:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/t
mp"
        </IfModule>
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        SuexecUserGroup gkk gkk
    </IfModule>
    ScriptAlias /cgi-bin/ /home/gkk/public_html/cgi-bin/

    Include "/usr/local/apache/conf/userdata/*.conf"  
    Include "/usr/local/apache/conf/userdata/*.owner-root" 
    Include "/usr/local/apache/conf/userdata/std/*.conf" 
    Include "/usr/local/apache/conf/userdata/std/*.owner-root" 
    Include "/usr/local/apache/conf/userdata/std/2/*.conf" 
    Include "/usr/local/apache/conf/userdata/std/2/*.owner-root" 
    Include "/usr/local/apache/conf/userdata/std/2/gkk/*.conf"  
    Include "/usr/local/apache/conf/userdata/std/2/gkk/mydomain.com/*.conf"

</VirtualHost>

<VirtualHost xx.xxx.xxx.196:80>
    ServerName myotherdomain.com
    ServerAlias www.myotherdomain.com
    DocumentRoot /home/gkk2/public_html
    ServerAdmin webmaster@webcompany.net
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/myotherdomain.com combined
    CustomLog /usr/local/apache/domlogs/myotherdomain.com-bytes_log "%{%s}t %I .\n%{%s}t %O
."
    ## User gkk2 # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup gkk2 gkk2
    </IfModule>
    <IfModule concurrent_php.c>
        php4_admin_value open_basedir "/home/gkk2:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/
tmp"
        php5_admin_value open_basedir "/home/gkk2:/usr/lib/php:/usr/local/lib/php:/tmp"
    </IfModule>
    <IfModule !concurrent_php.c>
        <IfModule mod_php4.c>
            php_admin_value open_basedir "/home/gkk2:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/ph
p:/tmp"
        </IfModule>
        <IfModule mod_php5.c>
            php_admin_value open_basedir "/home/gkk2:/usr/lib/php:/usr/local/lib/php:/tmp"
        </IfModule>
        <IfModule sapi_apache2.c>
            php_admin_value open_basedir "/home/gkk2:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/ph
p:/tmp"
        </IfModule>
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        SuexecUserGroup gkk2 gkk2
    </IfModule>
    ScriptAlias /cgi-bin/ /home/gkk2/public_html/cgi-bin/

    Include "/usr/local/apache/conf/userdata/*.conf"  
    Include "/usr/local/apache/conf/userdata/*.owner-root" 
    Include "/usr/local/apache/conf/userdata/std/*.conf" 
    Include "/usr/local/apache/conf/userdata/std/*.owner-root" 
    Include "/usr/local/apache/conf/userdata/std/2/*.conf" 
    Include "/usr/local/apache/conf/userdata/std/2/*.owner-root"

</VirtualHost>

----- Original Message ----- 
From: "André Warnier" <aw@ice-sa.com> 
To: "Tomcat Users List" <users@tomcat.apache.org> 
Sent: Thursday, February 16, 2012 1:08:45 PM 
Subject: Re: mod_jk doesn't map to software-generated web address, but maps to this address
when I enter it into browser 

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

modjklist@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-unsubscribe@tomcat.apache.org 
For additional commands, e-mail: users-help@tomcat.apache.org 


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


Mime
View raw message