I apologize if this is the wrong list, but I think it should be the right one.
Tomcat writes session cookies with the webapp name in the cookie's path field, but I map URLs by domain to hide the webapp name, with mod_rewrite. So my sessions ain't stickin', 'cause the browser does not know to send up the cookie. The problem: Sessions won't take hold, because I use mod_rewrite in Apache to change http://www.domain.com/ to http://www.domain.com/webapp without redirection, before sending it off through mod_jk to tomcat on another server. Now, that being said, I have sessions working when I use http://www.domain.com/webapp/ explicitly and configure things to leverage that. But I want to hide the webapp subdir from the browsing experience. I run multiple sites, and each site has a webapp on my tomcat machine, which has one instance of tomcat running. End desired goal: A) www.domain.com in user's browser. B) multiple webapps in ONE tomcat instance, to reduce memory usage. I want to avoid separate tomcat instances for each website. C) Sessions that work with www.domain.com in the browser. [i.e. no webapp sub-dir name] D) Use Apache, mod_jk and Tomcat. And mod_rewrite where needed. My setup: Apache: 1.3.27 Tomcat: 4.1.27 Example of how I have apache virtual hosts setup: <VirtualHost [ipaddresshere]:80> RewriteEngine on ServerName www.domain.com ServerAdmin [EMAIL PROTECTED] DocumentRoot /home/appman/sites ErrorLog logs/domain_error.log CustomLog logs/domain_access.log combined #rewrites URLS for directories to webapp with index.jsp RewriteRule ^(.*)/$ /webappname$1/index.jsp [NS,PT,L] #rewrites plain www.domain.com to the webapp homepage jsp RewriteRule ^$ /webappname/index.jsp [NS,PT,L] #rewrites all explicit jsp file requests to have webappname. RewriteRule ^(.*) /webappname$1 [NS,PT,L] #all modrewrites use pass-through and Last, to avoid explicit redirect, and to only rewrite once. #it then goes to mod_jk JkMount /* server4 </VirtualHost> * * * * My server.xml file, below the connectors: <Host name="www.generaldomainofappserver.com" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Alias>www.domain.com</Alias> <Alias>www.domain2.com</Alias> <!-- ... About 20 domains aliased here, one for each site I'm running --> <Context path="/webappname" docBase="webappname" debug="0"></Context> <Context path="/webappnametwo" docBase="webappnametwo" debug="0"></Context> <!-- ... About 20 webapps listed here, one for each site I'm running --> </Host> * * * * workers.properties: worker.server4.type=ajp13 worker.server4.lbfactor=1 worker.server4.port=MODJKCONNECTORPORT worker.server4.host=IP_OF_TOMCAT_MACHINE worker.server4.socket_keepalive=1 worker.server4.cachesize=20 worker.server4.cache_timeout=600 So, my questions: 1) Can I get around this by having multiple "Host" descriptors in my server.xml, one for each domain, and having each one use a context descriptor like: <Context path="/" docBase="webappname"></Context> in effect, making each webapp its own root webapp? I tried that out, but it didn't deploy correctly. Perhaps because the two HOST descriptors I used had the same appBase, "webapps"? Perhaps the autoDeploy was double deploying the webapp to both Hosts, causing trouble? Could I put each site's "appBase" into its own folder, and would that solve the problem? I've searched the archives for information on this to no avail. Of course perhaps I was searching on the wrong terms... I've also investigated modifying the Tomcat source code, specifically around line 618 in org.apache.catalina.connector.HttpResponseBase.java , to get rid of anything that says, when writing a session cookie, " cookie.setPath(contextPath);" --- and just have it set it as " cookie.setPath("/"); ". I tried that, but there may be other classes involved in session cookie setting, because my session cookies still came up on my browser as having the "/webappname" as the cookie path... Perhaps the jk connector java code needs to be modified, too? Could it be that Apache, after having re-written the url to have the webapp name, makes the cookies being set keep that sub-dir? I'm ignorant about how cookies get passed back through the chain from Tomcat, to mod_jk, to Apache and to the browser. I'm working with the assumption that only Tomcat is really involved, and it's just more response header data being sent back -- ideally mod_jk and apache shouldn't care about how I set the cookies... Thanks so much for your help -- let me know if I can be of assistance in return -- I'm willing to trade services or trouble-shooting advice for someone who can help solve this for me, for what its worth. Thanks! -Brendan --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]