Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to force Jetty to only use HTTPS?

Tags:

https

ssl

jetty

I'm trying to force Jetty to only use HTTPS (or redirect to HTTPS from HTTP).

So far, I can access the server using both HTTP and HTTPS.

Here's the connector configuration:

<Call name="addConnector">
    <Arg>
      <New class="org.mortbay.jetty.nio.SelectChannelConnector">
        <Set name="port"><SystemProperty name="jetty.port" default="8888"/></Set>
        <Set name="maxIdleTime">30000</Set>
        <Set name="Acceptors">2</Set>
        <Set name="statsOn">false</Set>
        <Set name="confidentialPort">8443</Set>
        <Set name="lowResourcesConnections">1000</Set>
        <Set name="lowResourcesMaxIdleTime">500</Set>
      </New>
    </Arg>
  </Call>

   <Call name="addConnector">
    <Arg>
      <New class="org.mortbay.jetty.security.SslSocketConnector">
        <Set name="Port">8443</Set>
        <Set name="maxIdleTime">30000</Set>
        <Set name="handshakeTimeout">2000</Set>
        <Set name="keystore"><SystemProperty name="jetty.home" default="." />/etc/keystore</Set>
        <Set name="password">aaa</Set>
        <Set name="keyPassword">bbb</Set>
        <Set name="truststore"><SystemProperty name="jetty.home" default="." />/etc/keystore</Set>
        <Set name="trustPassword">aaa</Set>
        <Set name="handshakeTimeout">2000</Set>
      </New>
    </Arg>
  </Call>

I've tried setting the default port as 8443 (in the first connector), that didn't work and generated an error.

like image 316
TechFanDan Avatar asked Feb 03 '23 18:02

TechFanDan


1 Answers

Remove the first <Call name="addConnector"> section, that's the one that adds the plain HTTP connector (org.mortbay.jetty.nio.SelectChannelConnector).

like image 156
Bruno Avatar answered Feb 11 '23 19:02

Bruno