Welcome! Log In Create A New Profile

Advanced

Set cookie Path

Posted by drimk 
Set cookie Path
March 23, 2011 07:23AM
Hi everyone,

I already apologize if this question has already been answered but i cannot make it work.

Here is my problem:

Nginx is serving the static files and is also connected to Tomcat.
So i proxy_pass :
proxy_pass http://127.0.0.1:8080/stage in my config file

i use also :

proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_header Set-Cookie;
rewrite ^/stage/(.*)$ /$1 permanent;

The rewrite makes the URLs working properly.
The problem is that i cannot login on my website because the cookie path delivered by nginx is incorrect:

HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 23 Mar 2011 11:15:09 GMT
Content-Type: text/html;charset=UTF-8
Connection: close
Vary: Accept-Encoding
Set-Cookie: JSESSIONID=B588382489FA5F369C9617DEF09E31E3; Path=/stage
Content-Language: en-US
Length: unspecified [text/html]

The Path should be '/' : Path=/

I know that i can configure the tomcat connector but i don't like this solution (anyway, it created problem in tomcat also). I would like the change the Cookie Path to '/' by only managing the nginx configuration.
by the way, ProxyPassReverseCookiePath /stage / works fine with Apache ;) but i would like to change to Nginx :)

Thank you for you help
Re: Set cookie Path
March 31, 2011 08:15PM
Instead of configuring the Connector with

emptySessionPath="true"

you can set

sessionCookiePath="/"

in the Context:
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Common_Attributes

I don't see that there are any methods available through nginx, although people have been looking for this feature since 2008:
http://markmail.org/message/64wxk6ijshoi6j7q

The mod can't be too hard to create, perhaps if I get some extra time...
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 165
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready