Permanently redirect from http to https in Jetty 9

2019-09-12 00:49发布

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条回答
Ridiculous、
2楼-- · 2019-09-12 01:22

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>
查看更多
登录 后发表回答