Permanently redirect from http to https in Jetty 9

旧时模样 提交于 2019-12-12 03:32:48

问题


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>

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 ?


回答1:


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

In your 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> 

In a Jetty XML

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


来源:https://stackoverflow.com/questions/42784532/permanently-redirect-from-http-to-https-in-jetty-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!