Http session couldn't hold in Tomcat and nginx proxypass using Spring mvc

冷暖自知 提交于 2019-12-08 08:57:18

问题


I am using Tomcat 7 and using nginx 1.5.7 as a load-balancer(on Windows 8). I configurated nginx server like this.

server {
    listen          80;
    server_name     www.something.com something.com;
    location / {
        proxy_pass http://127.0.0.1:8080/webapp/;
    }
}

Also I redirect in my "hosts" file: 127.0.0.1 www.something.com

But after login or any session operation via post, there is no session holding in my webapp, It is behaving like no session parameters.

By the way i tried to add in web.xml file

<session-config>
      <tracking-mode>COOKIE</tracking-mode>
</session-config>

But nothing changes.

So what is the problem in this state?

Thanks for your helps.


回答1:


You have changed the path to the web application in the proxy (/ -> /webapp). This is generally a bad idea as it breaks a whole bunch of stuff that you then need to fix. In this case it is probably the cookie path that is your immediate problem. To fix that you need to use the proxy_cookie_path directive. Once you fix that expect to find other problems.

You'd actually be better off redeploying your web application as the ROOT web app so that your proxy_pass directive becomes proxy_Pass http://127.0.0.1:8080/;



来源:https://stackoverflow.com/questions/20623099/http-session-couldnt-hold-in-tomcat-and-nginx-proxypass-using-spring-mvc

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