使用Spring MVC无法在Tomcat和Nginx proxypass中保持HTTP会话

编程入门 行业动态 更新时间:2024-10-25 10:30:58
本文介绍了使用Spring MVC无法在Tomcat和Nginx proxypass中保持HTTP会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Tomcat 7,并使用nginx 1.5.7作为负载平衡器(在Windows 8上).我像这样配置nginx服务器.

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 something; location / { proxy_pass 127.0.0.1:8080/webapp/; } }

我也重定向到我的主机"文件中:127.0.0.1 www.something

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

但是在登录或通过发布进行任何会话操作之后,我的web应用程序中没有会话保持,这就像没有会话参数一样.

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

通过我尝试在web.xml文件中添加的方式

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

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

但是什么都没有改变.

那么在这种状态下是什么问题?

So what is the problem in this state?

感谢您的帮助.

推荐答案

您已在代理(/->/webapp)中更改了Web应用程序的路径.通常这是一个坏主意,因为它会破坏您需要修复的一堆东西.在这种情况下,可能是cookie路径是您的直接问题.要解决此问题,您需要使用proxy_cookie_path指令.修复该问题后,还会发现其他问题.

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.

实际上,最好将Web应用程序重新部署为ROOT Web应用程序,以便您的proxy_pass指令变为proxy_Pass 127.0.0.1:8080/;

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

更多推荐

使用Spring MVC无法在Tomcat和Nginx proxypass中保持HTTP会话

本文发布于:2023-07-15 10:29:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1110670.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Tomcat   MVC   Spring   HTTP   proxypass

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!