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

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

问题描述

您好,我试图在Jetty 9中设置从http到https的永久重定向(301).解决方案是在我的web.xml中添加以下内容

Hello I am trying to setup a permanent redirect (301) from http to https in jetty 9. The solution I found everywhere is to add the following in my web.xml

    <security-constraint>
  <web-resource-collection>
   <web-resource-name>Everything</web-resource-name>
   <url-pattern>/*</url-pattern>
  </web-resource-collection>
  <user-data-constraint>
   <transport-guarantee>INTEGRAL</transport-guarantee>
  </user-data-constraint>
</security-constraint>

这设置了302重定向而不是301重定向,这是一个大问题,有人知道我可以将其更改为301重定向吗?

This sets up a 302 redirect and not a 301 redirect and it is a big issue, anyone know how I could change this to a 301 redirect ?

推荐答案

我认为您在运输保证中犯了一个错误,因此您必须改用它

I think you make a mistake in transport guarantee so you have to put this instead

在您的WEB-INF/web.xml

<security-constraint>
  <web-resource-collection>
    <web-resource-name>Everything</web-resource-name>
    <url-pattern>/*</url-pattern>
  </web-resource-collection>
  <user-data-constraint>
    <transport-guarantee>CONFIDENTIAL</transport-guarantee>
  </user-data-constraint>
</security-constraint> 

在Jetty XML中

In a Jetty XML

<Call name="addConnector">
   <Arg>
      <New class="org.eclipse.jetty.nio.SelectChannelConnector">
         ...
         <Set name="confidentialPort">443</Set>
      </New>
   </Arg>
</Call>

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

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