在Jetty中从http重定向到https [英] redirect from http to https in Jetty

查看:451
本文介绍了在Jetty中从http重定向到https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want make permanent redirect from http:// myurl to https:// myurl, but in Jetty I find only MovedContextHandler, with it I can redirect only context path, for examnple from myurl/bla to 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前缀?

but how can I work with prefix of url?

推荐答案

最好在您的/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>

这篇关于在Jetty中从http重定向到https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆