How to Redirect HTTP to HTTPS in Jetty 9

Goal

Set up Jetty 9 to redirect all HTTP requests to HTTPS instead of disabling the HTTP connector after Enabling SSL in verison 5.2 and later.

Learn

Open

<datameer-install-path/etc/webdefault.xml>

in an editor and add

<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 the appropriate section.

Test redirection using

curl --verbose 'http://localhost:8080'