If you want multiple name-based virtual hosts with JK, I have found that you need to do the following:


- make sure NameVirtualHost is enabled and set to "*"

- make sure all VirtualHost containers look like this:

<VirtualHost *>
 ServerName your.host.name
 ...
 JkMount /*.jsp ajp13
</VirtualHost>

- make sure that every possible value of ServerName is also defined in server.xml either as a Host or an Alias to a Host.

You're getting the default web-app because Tomcat doesn't have a virtual host defined for "127.0.0.1", nor should it (technically) as virtual hosts are typically name-based. Most likely you have virtual hosts for "localhost" and "ocean-stprg", but as far as Tomcat is concerned, neither of those is equal to "127.0.0.1", which is probably the host header it is getting from Apache.

I have this configuration currently setup for 6 hosts, it is working perfectly. If you take the "127.0.0.1" out of your VirtualHost containers and instead use the "*" and follow the other things above, you should be fine. You'll also want to make sure that you designate a separate appBase for each Host in server.xml.

John

On Fri, 27 Jun 2003 12:14:54 +0100, Heather Buch <[EMAIL PROTECTED]> wrote:

Hello,

My NameVirtualHost fails when I try to set the JkMount directives.

I am using
httpd-2.0.43
jakarta-tomcat-4.1.12
(I am also using jakarta-struts-1.0.2, but this might not be so relevant to my
problem)


Here is my setup (I describe the problem at the end using the specific names
that appear in the config file snippets below):


1. in /etc/hosts:

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
127.0.0.1               oecon-stprg
127.0.0.1               oecon-admprg
12.38.84.60             heather

2. In httpd.conf:

NameVirtualHost 127.0.0.1

Here is my "catch all" localhost virtual host:

<VirtualHost 127.0.0.1>
ServerAdmin [EMAIL PROTECTED]
ServerAlias localhost.localdomain localhost
DocumentRoot "/usr/local/bin/server-1.0/apache2/htdocs"
ServerName localhost
ErrorLog logs/localhost_error.log
CustomLog logs/localhost_access.log common
</VirtualHost>

3. in mod_jk.conf-local

Here is the virtual host that I am trying to work with:

<VirtualHost 127.0.0.1>
DocumentRoot
"/usr/local/bin/server-1.0/jakarta-tomcat-4.1.12/webapps/oecon-stprg/"
ServerName oecon-stprg
ServerAlias oecon-stprg
ServerAdmin [EMAIL PROTECTED]

# Deny direct access to WEB-INF and META-INF
<Location "WEB-INF/*">
AllowOverride None
deny from all
</Location>
<Location "META-INF/*">
AllowOverride None
deny from all
</Location>
<Directory "/usr/local/bin/server-1.0/jakarta-tomcat- 4.1.12/webapps/oecon-stprg">
Options Indexes FollowSymLinks
order allow,deny
allow from all
DirectoryIndex login.jsp </Directory>


JkMount /*.do ajp13
JkMount /servlet/*.jsp ajp13
JkMount /*.jsp ajp13

#ErrorLog logs/oecon-stprg_error.log
#CustomLog logs/oecon-stprg_access.log common
</VirtualHost>


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


The problem is - when I call up my virtual host url (http://oecon-stprg) and
comment out the JkMount directives, apache gives me the proper document root
("/usr/local/bin/server-1.0/jakarta-tomcat-4.1.12/webapps/oecon-stprg/") but
of course then Tomcat can't handle jsp pages because there are no JkMount
directives. When I uncomment the JkMounts and call up my virtual host, Apache
does not send me to the DocumentRoot that I have defined in my oecon- stprg
VirtualHost, but instead to the default tomcat webapp.


In other words, the presence of this in my VirtualHost block:

JkMount /*.do ajp13
JkMount /servlet/*.jsp ajp13
JkMount /*.jsp ajp13

causes Apache to deliver the files under here:

/usr/local/bin/server-1.0/jakarta-tomcat-4.1.12/webapps/ROOT

intead of the ones under here:

/usr/local/bin/server-1.0/jakarta-tomcat-4.1.12/webapps/oecon-stprg

I hope I have explained this well enough to get a reply. I have struggled for
two days now. I read the document at
http://www.galatea.com/flashguides/virtual-hosting.xml as I generally think
the Galatea guides are very good. However, it describes setting up the
JkMounts under a subdirectory, for example,


JkMount /test ajp13
JkMount /test/* ajp13

and not at the root, as I would like to do. I want to be able to call up

http://oecon-stprg/login.jsp

not

http://oecon-stprg/test/login.jsp

but maybe I need that subdirectory?

Thanks very much in advance,

Heather Buch


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to