You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Tim Dellas <de...@ascora.de> on 2010/08/02 17:35:52 UTC

Struts2 session problem (after migrating behind reverse proxy)

Hi there!

 

I store session parameters in a Struts2 session map that I get in my actions
using the SessionAware interface. My Application is in the /MyApp path.

 

After setting up the struts2 application on an Apache server with an inverse
proxy redirect that makes the URL http://www.appdomain.com/ point to my
local tomcat on localhost:8080/MyApp, Struts2 session handling doesn't work
anymore. I expect that the session cookies are stored for the Struts2
context of http://localhost:8080/MyApp instead of http://www.appdomain.com/
.

 

Is there a solution in Struts2 configuration? Or in programmatically
changing the session cookie somehow? Couldn't find any info about this on
the interwebs or in the official documentation. Please help, I'm already in
production and my logins don't work ;-)

 

Best regards, Tim

(hope I don't do wrong by posting here, not using mailing lists often but
will try to help others too)


AW: Struts2 session problem (after migrating behind reverse proxy)

Posted by Tim Dellas <de...@ascora.de>.
Hi Nuwan!

To be frank: I don't know - I don't have access to the production server and
just push up my .WARs. But just to let everyone know:

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.

<s:if test='sessionid && !sessionid.equals("")'>
<script type="text/javascript">
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","<s:property value='sessionid'
/>",3);
		});
</script>
</s:if>

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

Thank you, problem solved!

Best Regards, 
Tim


-----Ursprüngliche Nachricht-----
Von: nuwan chandrasoma [mailto:mymailnot@gmail.com] 
Gesendet: Dienstag, 3. August 2010 12:31
An: Struts Users Mailing List
Betreff: Re: Struts2 session problem (after migrating behind reverse proxy)

Hi Tim,

what is your apache webserver version? i have you tried with a
ProxyPassReverse declaration?

Thanks,

Nuwan C.

On Mon, Aug 2, 2010 at 9:05 PM, Tim Dellas <de...@ascora.de> wrote:

> Hi there!
>
>
>
> I store session parameters in a Struts2 session map that I get in my 
> actions using the SessionAware interface. My Application is in the 
> /MyApp path.
>
>
>
> After setting up the struts2 application on an Apache server with an 
> inverse proxy redirect that makes the URL http://www.appdomain.com/ 
> point to my local tomcat on localhost:8080/MyApp, Struts2 session 
> handling doesn't work anymore. I expect that the session cookies are 
> stored for the Struts2 context of http://localhost:8080/MyApp instead 
> of http://www.appdomain.com/ .
>
>
>
> Is there a solution in Struts2 configuration? Or in programmatically 
> changing the session cookie somehow? Couldn't find any info about this 
> on the interwebs or in the official documentation. Please help, I'm 
> already in production and my logins don't work ;-)
>
>
>
> Best regards, Tim
>
> (hope I don't do wrong by posting here, not using mailing lists often 
> but will try to help others too)
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2 session problem (after migrating behind reverse proxy)

Posted by nuwan chandrasoma <my...@gmail.com>.
Hi Tim,

what is your apache webserver version? i have you tried with a
ProxyPassReverse declaration?

Thanks,

Nuwan C.

On Mon, Aug 2, 2010 at 9:05 PM, Tim Dellas <de...@ascora.de> wrote:

> Hi there!
>
>
>
> I store session parameters in a Struts2 session map that I get in my
> actions
> using the SessionAware interface. My Application is in the /MyApp path.
>
>
>
> After setting up the struts2 application on an Apache server with an
> inverse
> proxy redirect that makes the URL http://www.appdomain.com/ point to my
> local tomcat on localhost:8080/MyApp, Struts2 session handling doesn't work
> anymore. I expect that the session cookies are stored for the Struts2
> context of http://localhost:8080/MyApp instead of
> http://www.appdomain.com/
> .
>
>
>
> Is there a solution in Struts2 configuration? Or in programmatically
> changing the session cookie somehow? Couldn't find any info about this on
> the interwebs or in the official documentation. Please help, I'm already in
> production and my logins don't work ;-)
>
>
>
> Best regards, Tim
>
> (hope I don't do wrong by posting here, not using mailing lists often but
> will try to help others too)
>
>