Chrome 和 JSESSIONID

发布于 2024-12-27 09:11:34 字数 1483 浏览 0 评论 0原文

chrome 出现以下问题...:

我在服务器上运行 Grails 1.3.7 应用程序。我注意到,当我从 Chrome 请求静态内容(例如非动态 html 文件)时,Chrome 会创建两个 JSESSIONID-Cookie。第一个是登录窗口出现时,第二个是成功登录后。如果我想刷新页面或请求其他资源,我必须再次登录。 (我想是因为Tomcat不理解这两个cookie)

我已经用FF尝试过了,但是FF只创建了一个Cookie并且它工作得很好。 另外,我已经在本地运行了该应用程序,即使在 Chrome 上也能完美运行。所以,一定是tomcat出了问题。

环境:

  • Grails-Application 1.3.7(带有 Spring-Security-Core 1.2.4)
  • Apache Tomcat 7(在 Windows Server 2008 上)

我的 httpd.conf:

ProxyPass /manager http://myUrl:8080/manager
ProxyPass /myGrailsApp http://myUrl:8080/myGrailsApp
ProxyPassReverse /manager http://myUrl:8080/manager
ProxyPassReverse /myGrailsApp http://myUrl:8080/myGrailsApp

ProxyPass / http://myUrl:8080/myGrailsApp/frontend
ProxyPassReverse / http://myUrl:8080/myGrailsApp/frontend

提前致谢。

更新1:

我重新构建、重新部署应用程序并再次重新启动tomcat。

现在我注意到:Chrome 不再生成两个 cookie。但错误是一样的。每次我刷新或请求某些内容时,JSESSIONID 都会发生变化,我必须重新登录。

tomcat 服务器上的简短监视显示大量活动会话 - 来自 chrome 的会话...

更新 2:

我在服务器上本地尝试了它(使用 chrome):

  • localhost/myApp/frontend = >阿帕奇 => 本地主机失败
  • :8080/myApp/frontend =>汤姆猫=>好吧,

看来 Apache 是问题所在(?)。

解决方案:

我明白了:) Grails *.gsp-Templates 总是在每个请求中请求“favicon.ico”。 错误出现在静态内容(如 html 文件)上的原因是我们从 Grails 应用程序重定向到这些资源。

所以我把 favicon.ico 放在正确的位置,现在它可以工作了:)

这个错误只涉及 Google Chrome,在 FF 和 IE 中它工作没有任何问题。

Following problem with chrome...:

I've running an Grails 1.3.7 Application on a Server. I've noticed, when I request a static content (such as non-dynamic html-files) from Chrome, Chrome creates two JSESSIONID-Cookies. The first one when the login-window shows up, and the second after a successfull login. If I want to refresh the page, or request another resource, I've to login again. (I think because Tomcat doesn't understand those two cookies)

I've tried it with FF, but FF just just creates one Cookie and its working perfectly.
Also, I've ran the app locally, and it works even with chrome perfectly. So, something with tomecat must be wrong.

Enviroment:

  • Grails-Application 1.3.7 (with Spring-Security-Core 1.2.4)
  • Apache Tomcat 7 (on Windows Server 2008)

My httpd.conf:

ProxyPass /manager http://myUrl:8080/manager
ProxyPass /myGrailsApp http://myUrl:8080/myGrailsApp
ProxyPassReverse /manager http://myUrl:8080/manager
ProxyPassReverse /myGrailsApp http://myUrl:8080/myGrailsApp

ProxyPass / http://myUrl:8080/myGrailsApp/frontend
ProxyPassReverse / http://myUrl:8080/myGrailsApp/frontend

Thanks in advance.

Update 1:

I re-builded, re-deployed the app and restarted tomcat again.

Now I noticed: Chrome doesn't generate two cookies anymore. But the error is the same. Every time I refresh or request something, the JSESSIONID changes and I have to log in again.

A short watch on the tomcat-server displays a big amount of active sessions - those from chrome...

Update 2:

I tried it locally on the server (with chrome):

  • localhost/myApp/frontend => Apache => FAIL
  • localhost:8080/myApp/frontend => Tomcat => OK

It seems like Apache is the problem (?).

Solution:

I've got it :)
The Grails *.gsp-Templates always requested the 'favicon.ico' on each request.
The reason why the error appeared on static content (like html-files) is because we redirect to those resources from our Grails-Application.

So I've put the favicon.ico in the right place, and now it works :)

This error just concerns Google Chrome, in FF and IE it worked without any problems.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

裸钻 2025-01-03 09:11:34

我也遇到了这个问题。我花了一段时间才弄清楚发生了什么(包括使用 Wireshark 进行嗅探),并且还花了更多时间来找到可行的解决方案。
最后我找到了这个帖子 https://vaadin.com/forum/-/message_boards/view_message /1216366

看来这是 Chrome/Safari(Webkit 浏览器?)及其处理重定向 cookie 的方式的问题。
简单的修复方法是将 context.xml 添加到我的 spring 项目中的 META-INF 目录中,其中包含

<?xml version='1.0' encoding='utf-8'?>
<Context sessionCookiePathUsesTrailingSlash='false'>
</Context>

新的 war 文件,然后重新部署。现在一切都按预期进行。

I also ran into this problem. It took me a while to figure out what was happening (including sniffing with Wireshark), and still more time to find a viable solution.
At last I found this thread https://vaadin.com/forum/-/message_boards/view_message/1216366

It seams that this is a problem with Chrome/Safari (Webkit browsers?) and the way they handle redirected cookies.
The simple fix was to add a context.xml to the META-INF directory in my spring project containing

<?xml version='1.0' encoding='utf-8'?>
<Context sessionCookiePathUsesTrailingSlash='false'>
</Context>

and then redeploying the new war file. Now everything is working as intended.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文