Re: JKMount, virtual hosts, and avoiding the webapp name
Mike Curwen wrote: So it's gonna be something like: The Apache Vhost: JKMount /*.jsp tomcat1 JKMount /fooservlet tomcat1 DocumentRoot /home/webhome/atm/htdocs/ ServerName www.foo.com ServerAlias foo.com ErrorLog /var/log/atm/error_log CustomLog /var/log/atm/access_log combined relates to the TC Host: foo.com Yeah, but I typically make DocumentRoot = ROOT docBase. So on my servers I have something like this: and ServerName www.VIRTHOST.aas.com DocumentRoot /usr/local/jakarta-tomcat-4.1.27/VIRTHOST/VIRTHOST # Static files Alias / "/usr/local/jakarta-tomcat-4.1.27/VIRTHOST/VIRTHOST" Options Indexes FollowSymLinks DirectoryIndex index.jsp # Deny direct access to WEB-INF and META-INF AllowOverride None deny from all AllowOverride None deny from all JkMount /* ajp13 Which makes the following dir structure possible: appBase $CATALINA_HOME/VIRTHOST Apache DocumentRoot, and TC root Context, path="", docBase="VIRTHOST": $CATALINA_HOME/VIRTHOST/VIRTHOST other Context, path="/SOME_OTHER_APP", docBase="SOME_OTHER_APP": $CATALINA_HOME/VIRTHOST/SOME_OTHER_APP Yes, #2 above is redundant with having the same dir name twice, but it makes sense to me. You could just as easily change it to ROOT or something else, but in my case, with many virtual hosts, I found myself saying "ok, this is ROOT, but WHICH ROOT?". Using the domain name as the actual name of the directory for the root web app gets rid of this problem. For other Contexts, you just add additional Alias commands to httpd.conf to get Apache to recognize dirs on the same level as the DocRoot instead of sub-dirs. Is that correct? In this case, I'm replacing /ATM and /BDG apps with to Hosts under TC, with the default Context set to be a separate instance of that 'common' app. Pretty much, I would just watch the DocumentRoot and Alias in httpd.conf, they can play tricks on you if you have them pointing to directories one level above or below your Context's docBase. I'm wondering about this from workers.properties: worker.list=tomcat1 worker.tomcat1.host=localhost Will I need to define a new work for each new host in TC,or can I supply a comma separated list to the worker.tomcat1.host entry? No, you only need one worker. ".host" = "location of machine running Tomcat", it does not need to match any virtual host name. I used to think it did, back in the day, but I have since seen the error of my ways and have come back to the straight and narrow. A basic 4-line workers.properties will work for many virtual hosts. I have servers with 5, 8, and 22 virtual hosts, all using one worker per physical server with no problems. Thanks very much John. :) Glad to help, if I am. Have fun. John - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JKMount, virtual hosts, and avoiding the webapp name
inlined replies... > -Original Message- > From: John Turner [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 03, 2003 3:28 PM > To: Tomcat Users List > Subject: Re: JKMount, virtual hosts, and avoiding the webapp name > > > > But how do I match up the requests from apache's virtual host > > www.foo.com to the /ATM context in Tomcat? Am I looking at > creating a > > new in Tomcat for each in apache? > > Yes. > > > And then the default webapp for each of my TC Hosts would > be the /ATM > > application? > > You mean sharing Contexts across Hosts? I don't think so. > Oops, I mispoke. We have a single application that we deploy multiple contexts of, so that each virtual host has its own copy of the application. So in my 'new' scheme, I'd specify that the default webapp is this 'common' application, but not 'shared' in the sense you thought, (because of my typing). > Your Context path is just "" with the same docBase. Then > your JkMounts are: > > JkMount /*.jsp worker-name > JkMount /something-typically-servlet/* ajp13 > > John > So it's gonna be something like: The Apache Vhost: JKMount /*.jsp tomcat1 JKMount /fooservlet tomcat1 DocumentRoot /home/webhome/atm/htdocs/ ServerName www.foo.com ServerAlias foo.com ErrorLog /var/log/atm/error_log CustomLog /var/log/atm/access_log combined relates to the TC Host: foo.com AND JKMount /*.jsp tomcat1 JKMount /fooservlet tomcat1 DocumentRoot /home/webhome/bdg/htdocs/ ServerName www.foo2.com ServerAlias foo2.com ErrorLog /var/log/bdg/error_log CustomLog /var/log/bdg/access_log combined relates to the TC Host: foo2.com Is that correct? In this case, I'm replacing /ATM and /BDG apps with to Hosts under TC, with the default Context set to be a separate instance of that 'common' app. I'm wondering about this from workers.properties: worker.list=tomcat1 worker.tomcat1.host=localhost Will I need to define a new work for each new host in TC,or can I supply a comma separated list to the worker.tomcat1.host entry? As for the 'illegal' and 'scary' mappings we have.. I'm sure we just picked them up from googling and well, you know how valid some of the info out there is. We've also got some attributes on Contexts that I can't find docos for. They don't seem to hurt though. After I've ironed out these issues, I'm doing a 'clean sweep' of all the files (after backup of course) and 'HOWTO' for myself and colleagues at work. Thanks very much John. :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JKMount, virtual hosts, and avoiding the webapp name
Mike Curwen wrote: I define an Apache Virtual Host in httpd.conf: JKMount /ATM tomcat1 JKMount /ATM/* tomcat1 I wouldn't do /ATM without a wildcard or something after it. DocumentRoot /home/webhome/atm/htdocs/ ServerName www.foo.com ServerAlias foo.com ErrorLog /var/log/atm/error_log CustomLog /var/log/atm/access_log combined And in Tomcat server.xml: (inside the localhost 'host' element) docBase="/home/webhome/atm/" defaultSessionTimeOut="60" reloadable="true" > So now to access regular static pages with apache, I just say: http://www.foo.com/xyz.html http://www.foo.com/pages/morepages/foo.html And to do servlet/jsp stuff: http://www.foo.com/ATM/servletFoo http://www.foo.com/ATM/foo.jsp http://www.foo.com/ATM/administer/admin.jsp This works fairly well, I suppose, but what about sites where MOST content is jsp/servlet based? I'd like my URLS to not require the /ATM token. You don't need it. So then I thought to do this (in apache): JKMount /*.jsp tomcat1 JKMount /*/*.jsp tomcat1 JKMount /servletFoo tomcat1 DocumentRoot /home/webhome/atm/htdocs/ ServerName www.foo.com ServerAlias foo.com ErrorLog /var/log/atm/error_log CustomLog /var/log/atm/access_log combined Double wildcards is "illegal". "/*.jsp" is equivalent to "/*/*.jsp" since the second "/" is covered by the "*" in "/*.jsp". But how do I match up the requests from apache's virtual host www.foo.com to the /ATM context in Tomcat? Am I looking at creating a new in Tomcat for each in apache? Yes. And then the default webapp for each of my TC Hosts would be the /ATM application? You mean sharing Contexts across Hosts? I don't think so. Your Context path is just "" with the same docBase. Then your JkMounts are: JkMount /*.jsp worker-name JkMount /something-typically-servlet/* ajp13 John - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
JKMount, virtual hosts, and avoiding the webapp name
I'm not sure I'm configuring things quite correctly, because it seems to me I should be able to do this with one less token... Apache 2 TC 4.1.24 JK My workers.properties: worker.list=tomcat1 worker.tomcat1.port=11009 worker.tomcat1.host=localhost worker.tomcat1.type=ajp13 I define an Apache Virtual Host in httpd.conf: JKMount /ATM tomcat1 JKMount /ATM/* tomcat1 DocumentRoot /home/webhome/atm/htdocs/ ServerName www.foo.com ServerAlias foo.com ErrorLog /var/log/atm/error_log CustomLog /var/log/atm/access_log combined And in Tomcat server.xml: (inside the localhost 'host' element) So now to access regular static pages with apache, I just say: http://www.foo.com/xyz.html http://www.foo.com/pages/morepages/foo.html And to do servlet/jsp stuff: http://www.foo.com/ATM/servletFoo http://www.foo.com/ATM/foo.jsp http://www.foo.com/ATM/administer/admin.jsp This works fairly well, I suppose, but what about sites where MOST content is jsp/servlet based? I'd like my URLS to not require the /ATM token. So then I thought to do this (in apache): JKMount /*.jsp tomcat1 JKMount /*/*.jsp tomcat1 JKMount /servletFoo tomcat1 DocumentRoot /home/webhome/atm/htdocs/ ServerName www.foo.com ServerAlias foo.com ErrorLog /var/log/atm/error_log CustomLog /var/log/atm/access_log combined But how do I match up the requests from apache's virtual host www.foo.com to the /ATM context in Tomcat? Am I looking at creating a new in Tomcat for each in apache? And then the default webapp for each of my TC Hosts would be the /ATM application? Thanks for any pointers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]