Struts2: Session Problem (after reverse proxy)

梦想的初衷 提交于 2019-12-01 22:48:44

This is old but I found it and would like to drop my 5 cents.

One fix that you can use is to edit the web.xml and in the session-config set something like:

<session-config>
    <session-timeout>10</session-timeout>
    <cookie-config>
        <name>MYAPPSESSIONID</name>
        <path>/</path>
    </cookie-config>
</session-config>

This changes

  • The sessionid cookie from JSESSIONID to MYAPPSESSIONID so it will not collide with other apps that may be exposed on the same proxy
  • The path that the cookie applies. So it will always be sent to the server

Hope this may help others.

I just solved the problem with a dirty hack: I passed the Session Id to the JSP and use a javascript to set the needed JSESSIONID cookie clientside.

function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; }

$(document).ready(function() { createCookie("JSESSIONID","",3); });

Got the JS code from this page: http://www.quirksmode.org/js/cookies.html

Thank you, problem solved!

Best Regards, Tim

Put this in your httpd.conf

#all cookies from /MyApp are proxied to "/"
ProxyPassReverseCookiePath /MyApp /

http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypassreversecookiepath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!