日期:2014-05-17 浏览次数:21103 次
问题描述:服务器上布暑了多个项目,其中一个使用主域名,其它的使用二级域名,现在需要在其中一个二级域名的网站中使用session功能,但发现每次布
新页面时取到的sessionId不一样!!!停掉apache,使用tomcat访问取得的session是正常的。目前可以确认是apache代理
tomcat时产生的问题,造成session丢失了。
---------------------------------
apache 2.2 + apache-tomcat-6.0.18
框架:struts2+Spring+Hibernate
目前采用 apache的 http_proxy 代理,配置如下:
tomcat端口:8088
apache端口:80
项目路径为:
E:\apache-tomcat-6.0.18\webapps\face
apache 中的配置为:? 
NameVirtualHost *
<VirtualHost *>
 ?   DocumentRoot "E:/apache-tomcat-6.0.18/webapps/face"
 ?   ServerName face.cn13e.com
	DirectoryIndex index.html
 ?   ErrorLog "logs/face-error.log"
 ?   #CustomLog "logs/face-access.log" common
 ?   ProxyPass /Downloads !
 ?   ProxyPass / http://127.0.0.1:8088/face/
 ?   ProxyPassReverse / http://127.0.0.1:8088/face/
	RewriteEngine on
	#rewritelog	logs/face-rewrite.log
	rewriteloglevel 0
	RewriteRule /(?:index.html)?$ /index.jsp [PT]
</VirtualHost>
Tomcat使用默认配置:
<Host name="localhost"  appBase="webapps"
 ?           unpackWARs="true" autoDeploy="true"
 ?           xmlValidation="false" xmlNamespaceAware="false">
 ?       <!-- SingleSignOn valve, share authentication between web applications
 ?            Documentation at: /docs/config/valve.html -->
 ?       <!--
 ?       <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
 ?       -->
 ?       <!-- Access log processes all example.
 ?            Documentation at: /docs/config/valve.html -->
 ?       <!--
 ?       <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" ? 
 ?              prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
 ?       -->
 ?     </Host>
从网上找到的解决方案:
修改tomcat:
<Host name="face.cn13e.com"  appBase="webapps"
 ?           unpackWARs="true" autoDeploy="true"
 ?           xmlValidation="false" xmlNamespaceAware="false">
			<Context path="" docBase="face" reloadable="true" />
修改apache:
 ?   ProxyPass / http://face.cn13e.com:8088/
 ?   ProxyPassReverse / http://face.cn13e.com:8088/
本方法确实能解决session丢失问题,但会造成\work\Catalina\ 目录下的项目布暑多次,引起内存溢出。