【问题标题】:302 server redirection - 'Location' header URL gets changed from HTTP to HTTPS302 服务器重定向 - 'Location' 标头 URL 从 HTTP 更改为 HTTPS
【发布时间】:2015-05-16 07:31:42
【问题描述】:

我有一个在 Tomcat 上运行的 Java Web 应用程序,并且正在尝试执行 302 重定向。

问题是:原始请求 URL 使用 HTTPS。我希望重定向 URL 使用 HTTP:

response.setHeader('Location', 'http://www.google.com');

由于某种原因,在使用 Wireshark 检查重定向包后,“Location”标头改为“https://www.google.com”。

我可以更改任何配置以使 Tomcat 尊重我在标头中设置的协议吗?

【问题讨论】:

  • 你确定不是 google 将他们的 OWN 重定向到 https 版本吗?
  • 我实际上只使用了 google 作为示例 - 我的网络应用程序中的 URL 也是如此。我还尝试了一个不支持 HTTPS 的站点。问题是,在我的客户端访问 URL 之前,它已被更改为 HTTPS

标签: tomcat redirect http-status-code-302 security-constraint


【解决方案1】:

您的 web.xml 是否具有类似于...的安全约束元素?

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Secure Web Pages</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>

    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

这将强制您的 http 请求为 https。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-16
    • 1970-01-01
    • 2011-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-12
    相关资源
    最近更新 更多