【问题标题】:redirect from http to https in Jetty在 Jetty 中从 http 重定向到 https
【发布时间】:2020-09-27 06:17:12
【问题描述】:

我想从 http://myurl 永久重定向到 https://myurl,但在 Jetty 中我只找到 MovedContextHandler,我只能重定向上下文路径,例如从 myurl/bla 到 myurl/bla/bla

<Configure class="org.mortbay.jetty.handler.MovedContextHandler">
  <Set name="contextPath">/bla</Set>
  <Set name="newContextURL">/bla/bla</Set>
  <Set name="permanent">true</Set>
  <Set name="discardPathInfo">false</Set>
  <Set name="discardQuery">false</Set>
</Configure>

但是我怎样才能使用 url 的前缀呢?

【问题讨论】:

标签: jetty


【解决方案1】:

最好在你的/WEB-INF/web.xml处理

<web-app>
  ...
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Everything in the webapp</web-resource-name>
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
      <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
</web-app>

【讨论】:

  • @joakim-erdfelt 当 Jetty 看到 403 !SECURE 错误时,是否推荐使用 SecureRequestCustomizer?见serverfault.com/a/575126我目前只有静态内容。
  • 如果您打算从 Jetty 终止的 SSL/TLS (https) 重定向到 (http),则需要 @gouessej SecureRequestCustomizer 来触发 Jetty 9+ 上的“安全”检查。但更重要的是需要在 SSL/TLS (https) ServerConnectors 上正确配置 HttpConfiguration(因为重定向使用该信息执行重定向)
  • 如何以编程方式为特定的上下文处理程序执行此操作?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-03-17
  • 2019-09-10
  • 2017-10-06
  • 2017-11-04
  • 2016-01-17
  • 2011-09-28
  • 2017-07-18
相关资源
最近更新 更多