首页 > 解决方案 > 从 nginx 代理到 Chrome 中的 java 应用程序时缺少 cookie

问题描述

在我们的 java 应用程序中,我们刚刚通过 x509 证书设置了身份验证。

它工作正常,只有一个例外是,当使用 nginx 代理应用程序和使用 Chrome 的用户时,注销 cookie 丢失。在 Mozilla FF cookie 中按预期设置

这是 FF 中的 cookie 在请求 /sd 时的样子

在此处输入图像描述

这就是这些在 Chrome 中的样子

在此处输入图像描述

如您所见,Chrome 中缺少 x509 cookie

如果我们使用 IIS 或根本不使用代理(仅 Tomcat),则两种浏览器的行为都是相同的。

这就是我设置cookie的方式:

public static Cookie getCookie(String value, int maxAge)
{
    Cookie cookie = new Cookie(X509ConfigProperties.COOKIE, value);
    cookie.setMaxAge(maxAge);
    cookie.setPath("/");
    return cookie;
}

也许我们只需要异常配置nginx config?

标签: javagoogle-chromenginxcookies

解决方案


推荐阅读