Forum: NGINX Cookies path rewrite

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8fba0eace1954a2c030db03c0f3ec95a?d=identicon&s=25 Ondrej Jombik (Guest)
on 2008-10-24 23:04
(Received via mailing list)
Greetings

I'm writing to this list, since I was unable to find solution online.

We are using nginx on our all servers and we are very satisfied.
Thank you very much for this wonderfull work!

One type of our usage is to serve Tomcat 5.5 applications on specified
desired domains. For example:

www.example.com <--[nginx]-->
http://tomcat-server.platon.sk:8180/AppDir/

This works great, however we need to use rewrite this way for removing
/AppDir/ from links, FORM actions and so on:

server {
     listen 80;
     server_name www.example.com;
     rewrite ^/AppDir/(.*) /$1;

     location / {
             proxy_pass  http://tomcat-server.platon.sk:8180/AppDir/;
     }
}

This also works great, however when application set up PATH in cookie,
in example cookie like this is sent:

Set-Cookie: JSESSIONID=4961D9D7519835620F9E6D0622F69ECA; Path=/AppDir

In this case, authentication is not working correctly, because this
cookie is set for PATH /AppDir and we are on PATH / on server
www.example.com (so not tomcat-server.platon.sk anymore).

Any suggestions and ideas would be greatly appreciated.

Thank you

Ondrej
4891b0faf6940a1992da2801b52c4735?d=identicon&s=25 Mark James (Guest)
on 2008-12-31 04:48
(Received via mailing list)
Ondrej Jombik wrote:

>     server_name www.example.com;
> Set-Cookie: JSESSIONID=4961D9D7519835620F9E6D0622F69ECA; Path=/AppDir
>
> In this case, authentication is not working correctly, because this
> cookie is set for PATH /AppDir and we are on PATH / on server
> www.example.com (so not tomcat-server.platon.sk anymore).
>
> Any suggestions and ideas would be greatly appreciated.

This solution worked for me:

http://ctotodevelopers.blogspot.com/2006/11/questi...
8fba0eace1954a2c030db03c0f3ec95a?d=identicon&s=25 Ondrej Jombik (Guest)
on 2009-01-04 22:48
(Received via mailing list)
We used solution, which reset all the cookie paths to simple '/'

It can be configured in Tomcat with:

     emptySessionPath="true"

So whole directive:

     <Connector port="8080" protocol="HTTP/1.1"
         connectionTimeout="20000"
         redirectPort="8443"
         emptySessionPath="true" />

But I would like to see better solution than this.

Ondrej
This topic is locked and can not be replied to.