title: Docker - Run Jetty on HTTPS
body: <p>I'm trying to configure my Jetty with SSL. Now I'm just stuck on why it doesn't connect on HTTPS. It works fine on HTTP though.</p>
  
  <blockquote>
    <p>${JETTY_HOME}/etc/jetty-https.xml</p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/config
  ure_9_3.dtd"&gt;
  
  &lt;!-- ============================================================= --&gt;
  &lt;!-- Configure a HTTPS connector.                                  --&gt;
  &lt;!-- This configuration must be used in conjunction with jetty.xml --&gt;
  &lt;!-- and jetty-ssl.xml.                                            --&gt;
  &lt;!-- ============================================================= --&gt;
  &lt;Configure id="sslConnector" class="org.eclipse.jetty.server.ServerConnector"&gt;
  
    &lt;Call name="addIfAbsentConnectionFactory"&gt;
      &lt;Arg&gt;
        &lt;New class="org.eclipse.jetty.server.SslConnectionFactory"&gt;
          &lt;Arg name="next"&gt;http/1.1&lt;/Arg&gt;
          &lt;Arg name="sslContextFactory"&gt;&lt;Ref refid="sslContextFactory"/&gt;&lt;/Arg&gt;
        &lt;/New&gt;
      &lt;/Arg&gt;
    &lt;/Call&gt;
  
    &lt;Call name="addConnectionFactory"&gt;
      &lt;Arg&gt;
        &lt;New class="org.eclipse.jetty.server.HttpConnectionFactory"&gt;
          &lt;Arg name="config"&gt;&lt;Ref refid="sslHttpConfig" /&gt;&lt;/Arg&gt;
          &lt;Arg name="compliance"&gt;&lt;Call class="org.eclipse.jetty.http.HttpCompliance" name="
  valueOf"&gt;&lt;Arg&gt;&lt;Property name="jetty.http.compliance" default="RFC7230"/&gt;&lt;/Arg&gt;&lt;/Call&gt;&lt;/Ar
  g&gt;
        &lt;/New&gt;
      &lt;/Arg&gt;
    &lt;/Call&gt;
  
  &lt;/Configure&gt;
  </code></pre>
  
  <blockquote>
    <p>${JETTY_HOME}/etc/jetty-ssl.xml</p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"&gt;
  
  &lt;!-- ============================================================= --&gt;
  &lt;!-- Base SSL configuration                                        --&gt;
  &lt;!-- This configuration needs to be used together with 1 or more   --&gt;
  &lt;!-- of jetty-https.xml or jetty-http2.xml                         --&gt;
  &lt;!-- ============================================================= --&gt;
  &lt;Configure id="Server" class="org.eclipse.jetty.server.Server"&gt;
  
    &lt;!-- =========================================================== --&gt;
    &lt;!-- Add a SSL Connector with no protocol factories              --&gt;
    &lt;!-- =========================================================== --&gt;
    &lt;Call  name="addConnector"&gt;
      &lt;Arg&gt;
        &lt;New id="sslConnector" class="org.eclipse.jetty.server.ServerConnector"&gt;
          &lt;Arg name="server"&gt;&lt;Ref refid="Server" /&gt;&lt;/Arg&gt;
          &lt;Arg name="acceptors" type="int"&gt;&lt;Property name="jetty.ssl.acceptors" deprecated="ssl.acceptors" default="-1"/&gt;&lt;/Arg&gt;
          &lt;Arg name="selectors" type="int"&gt;&lt;Property name="jetty.ssl.selectors" deprecated="ssl.selectors" default="-1"/&gt;&lt;/Arg&gt;
          &lt;Arg name="factories"&gt;
            &lt;Array type="org.eclipse.jetty.server.ConnectionFactory"&gt;
              &lt;!-- uncomment to support proxy protocol
              &lt;Item&gt;
                &lt;New class="org.eclipse.jetty.server.ProxyConnectionFactory"/&gt;
              &lt;/Item&gt;--&gt;
            &lt;/Array&gt;
          &lt;/Arg&gt;
  
          &lt;Set name="host"&gt;&lt;Property name="jetty.ssl.host" deprecated="jetty.host" /&gt;&lt;/Set&gt;
          &lt;Set name="port"&gt;&lt;Property name="jetty.ssl.port" deprecated="ssl.port" default="8443" /&gt;&lt;/Set&gt;
          &lt;Set name="idleTimeout"&gt;&lt;Property name="jetty.ssl.idleTimeout" deprecated="ssl.timeout" default="30000"/&gt;&lt;/Set&gt;
          &lt;Set name="soLingerTime"&gt;&lt;Property name="jetty.ssl.soLingerTime" deprecated="ssl.soLingerTime" default="-1"/&gt;&lt;/Set&gt;
          &lt;Set name="acceptorPriorityDelta"&gt;&lt;Property name="jetty.ssl.acceptorPriorityDelta" deprecated="ssl.acceptorPriorityDelta" default="0"/&gt;&lt;/Set&gt;
          &lt;Set name="acceptQueueSize"&gt;&lt;Property name="jetty.ssl.acceptQueueSize" deprecated="ssl.acceptQueueSize" default="0"/&gt;&lt;/Set&gt;
        &lt;/New&gt;
      &lt;/Arg&gt;
    &lt;/Call&gt;
  
    &lt;!-- =========================================================== --&gt;
    &lt;!-- Create a TLS specific HttpConfiguration based on the        --&gt;
    &lt;!-- common HttpConfiguration defined in jetty.xml               --&gt;
    &lt;!-- Add a SecureRequestCustomizer to extract certificate and    --&gt;
    &lt;!-- session information                                         --&gt;
    &lt;!-- =========================================================== --&gt;
    &lt;New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration"&gt;
      &lt;Arg&gt;&lt;Ref refid="httpConfig"/&gt;&lt;/Arg&gt;
      &lt;Call name="addCustomizer"&gt;
        &lt;Arg&gt;
          &lt;New class="org.eclipse.jetty.server.SecureRequestCustomizer"&gt;
            &lt;Arg name="sniHostCheck" type="boolean"&gt;&lt;Property name="jetty.ssl.sniHostCheck" default="true"/&gt;&lt;/Arg&gt;
            &lt;Arg name="stsMaxAgeSeconds" type="int"&gt;&lt;Property name="jetty.ssl.stsMaxAgeSeconds" default="-1"/&gt;&lt;/Arg&gt;
            &lt;Arg name="stsIncludeSubdomains" type="boolean"&gt;&lt;Property name="jetty.ssl.stsIncludeSubdomains" default="false"/&gt;&lt;/Arg&gt;
          &lt;/New&gt;
        &lt;/Arg&gt;
      &lt;/Call&gt;
    &lt;/New&gt;
  &lt;/Configure&gt;
  </code></pre>
  
  <p>After running <code>docker ps -a</code> :</p>
  
  <pre><code>root@myserver:/home/deploy/frontend/src/app/environments# docker ps -a
  CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS                        PORTS                                         NAMES
  9bf8f257f8ac        jetty                "/docker-entrypoint.s"   2 days ago          Up 14 minutes                 0.0.0.0:80-&gt;8080/tcp, 0.0.0.0:443-&gt;8443/tcp   jetty
  </code></pre>
  
  <p>And finally my </p>
  
  <blockquote>
    <p>${JETTY_HOME}/etc/jetty.xml</p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"&gt;
  
  &lt;!-- =============================================================== --&gt;
  &lt;!-- Documentation of this file format can be found at:              --&gt;
  &lt;!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax        --&gt;
  &lt;!--                                                                 --&gt;
  &lt;!-- Additional configuration files are available in $JETTY_HOME/etc --&gt;
  &lt;!-- and can be mixed in. See start.ini file for the default         --&gt;
  &lt;!-- configuration files.                                            --&gt;
  &lt;!--                                                                 --&gt;
  &lt;!-- For a description of the configuration mechanism, see the       --&gt;
  &lt;!-- output of:                                                      --&gt;
  &lt;!--   java -jar start.jar -?                                        --&gt;
  &lt;!-- =============================================================== --&gt;
  
  &lt;!-- =============================================================== --&gt;
  &lt;!-- Configure a Jetty Server instance with an ID "Server"           --&gt;
  &lt;!-- Other configuration files may also configure the "Server"       --&gt;
  &lt;!-- ID, in which case they are adding configuration to the same     --&gt;
  &lt;!-- instance.  If other configuration have a different ID, they     --&gt;
  &lt;!-- will create and configure another instance of Jetty.            --&gt;
  &lt;!-- Consult the javadoc of o.e.j.server.Server for all              --&gt;
  &lt;!-- configuration that may be set here.                             --&gt;
  &lt;!-- =============================================================== --&gt;
  &lt;Configure id="Server" class="org.eclipse.jetty.server.Server"&gt;
  
      &lt;!-- =========================================================== --&gt;
      &lt;!-- Configure the Server Thread Pool.                           --&gt;
      &lt;!-- The server holds a common thread pool which is used by      --&gt;
      &lt;!-- default as the executor used by all connectors and servlet  --&gt;
      &lt;!-- dispatches.                                                 --&gt;
      &lt;!--                                                             --&gt;
      &lt;!-- Configuring a fixed thread pool is vital to controlling the --&gt;
      &lt;!-- maximal memory footprint of the server and is a key tuning  --&gt;
      &lt;!-- parameter for tuning.  In an application that rarely blocks --&gt;
      &lt;!-- then maximal threads may be close to the number of 5*CPUs.  --&gt;
      &lt;!-- In an application that frequently blocks, then maximal      --&gt;
      &lt;!-- threads should be set as high as possible given the memory  --&gt;
      &lt;!-- available.                                                  --&gt;
      &lt;!--                                                             --&gt;
      &lt;!-- Consult the javadoc of o.e.j.util.thread.QueuedThreadPool   --&gt;
      &lt;!-- for all configuration that may be set here.                 --&gt;
      &lt;!-- =========================================================== --&gt;
      &lt;!-- uncomment to change type of threadpool
      &lt;Arg name="threadpool"&gt;&lt;New id="threadpool" class="org.eclipse.jetty.util.thread.QueuedThreadPool"/&gt;&lt;/Arg&gt;
      --&gt;
      &lt;Get name="ThreadPool"&gt;
        &lt;Set name="minThreads" type="int"&gt;&lt;Property name="jetty.threadPool.minThreads" deprecated="threads.min" default="10"/&gt;&lt;/Set&gt;
        &lt;Set name="maxThreads" type="int"&gt;&lt;Property name="jetty.threadPool.maxThreads" deprecated="threads.max" default="200"/&gt;&lt;/Set&gt;
        &lt;Set name="idleTimeout" type="int"&gt;&lt;Property name="jetty.threadPool.idleTimeout" deprecated="threads.timeout" default="60000"/&gt;&lt;/Set&gt;
        &lt;Set name="detailedDump"&gt;false&lt;/Set&gt;
      &lt;/Get&gt;
  
      &lt;!-- =========================================================== --&gt;
      &lt;!-- Add shared Scheduler instance                               --&gt;
      &lt;!-- =========================================================== --&gt;
      &lt;Call name="addBean"&gt;
        &lt;Arg&gt;
          &lt;New class="org.eclipse.jetty.util.thread.ScheduledExecutorScheduler"/&gt;
        &lt;/Arg&gt;
      &lt;/Call&gt;
  
      &lt;!-- =========================================================== --&gt;
      &lt;!-- Http Configuration.                                         --&gt;
      &lt;!-- This is a common configuration instance used by all         --&gt;
      &lt;!-- connectors that can carry HTTP semantics (HTTP, HTTPS, etc.)--&gt;
      &lt;!-- It configures the non wire protocol aspects of the HTTP     --&gt;
      &lt;!-- semantic.                                                   --&gt;
      &lt;!--                                                             --&gt;
      &lt;!-- This configuration is only defined here and is used by      --&gt;
      &lt;!-- reference from other XML files such as jetty-http.xml,      --&gt;
      &lt;!-- jetty-https.xml and other configuration files which         --&gt;
      &lt;!-- instantiate the connectors.                                 --&gt;
      &lt;!--                                                             --&gt;
      &lt;!-- Consult the javadoc of o.e.j.server.HttpConfiguration       --&gt;
      &lt;!-- for all configuration that may be set here.                 --&gt;
      &lt;!-- =========================================================== --&gt;
      &lt;New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration"&gt;
        &lt;Set name="secureScheme"&gt;&lt;Property name="jetty.httpConfig.secureScheme" default="https" /&gt;&lt;/Set&gt;
        &lt;Set name="securePort"&gt;&lt;Property name="jetty.httpConfig.securePort" deprecated="jetty.secure.port" default="8443" /&gt;&lt;/Set&gt;
        &lt;Set name="outputBufferSize"&gt;&lt;Property name="jetty.httpConfig.outputBufferSize" deprecated="jetty.output.buffer.size" default="32768" /&gt;&lt;/Set&gt;
        &lt;Set name="outputAggregationSize"&gt;&lt;Property name="jetty.httpConfig.outputAggregationSize" deprecated="jetty.output.aggregation.size" default="8192" /&gt;&lt;/Set&gt;
        &lt;Set name="requestHeaderSize"&gt;&lt;Property name="jetty.httpConfig.requestHeaderSize" deprecated="jetty.request.header.size" default="8192" /&gt;&lt;/Set&gt;
        &lt;Set name="responseHeaderSize"&gt;&lt;Property name="jetty.httpConfig.responseHeaderSize" deprecated="jetty.response.header.size" default="8192" /&gt;&lt;/Set&gt;
        &lt;Set name="sendServerVersion"&gt;&lt;Property name="jetty.httpConfig.sendServerVersion" deprecated="jetty.send.server.version" default="true" /&gt;&lt;/Set&gt;
        &lt;Set name="sendDateHeader"&gt;&lt;Property name="jetty.httpConfig.sendDateHeader" deprecated="jetty.send.date.header" default="false" /&gt;&lt;/Set&gt;
        &lt;Set name="headerCacheSize"&gt;&lt;Property name="jetty.httpConfig.headerCacheSize" default="512" /&gt;&lt;/Set&gt;
        &lt;Set name="delayDispatchUntilContent"&gt;&lt;Property name="jetty.httpConfig.delayDispatchUntilContent" deprecated="jetty.delayDispatchUntilContent" default="true"/&gt;&lt;/Set&gt;
        &lt;Set name="maxErrorDispatches"&gt;&lt;Property name="jetty.httpConfig.maxErrorDispatches" default="10"/&gt;&lt;/Set&gt;
        &lt;Set name="blockingTimeout"&gt;&lt;Property name="jetty.httpConfig.blockingTimeout" default="-1"/&gt;&lt;/Set&gt;
        &lt;Set name="persistentConnectionsEnabled"&gt;&lt;Property name="jetty.httpConfig.persistentConnectionsEnabled" default="true"/&gt;&lt;/Set&gt;
        &lt;Set name="cookieCompliance"&gt;&lt;Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"&gt;&lt;Arg&gt;&lt;Property name="jetty.httpConfig.cookieCompliance" default="RFC6265"/&gt;&lt;/Arg&gt;&lt;/Call&gt;&lt;/Set&gt;
      &lt;/New&gt;
  
      &lt;!-- =========================================================== --&gt;
      &lt;!-- Set the default handler structure for the Server            --&gt;
      &lt;!-- A handler collection is used to pass received requests to   --&gt;
      &lt;!-- both the ContextHandlerCollection, which selects the next   --&gt;
      &lt;!-- handler by context path and virtual host, and the           --&gt;
      &lt;!-- DefaultHandler, which handles any requests not handled by   --&gt;
      &lt;!-- the context handlers.                                       --&gt;
      &lt;!-- Other handlers may be added to the "Handlers" collection,   --&gt;
      &lt;!-- for example the jetty-requestlog.xml file adds the          --&gt;
      &lt;!-- RequestLogHandler after the default handler                 --&gt;
      &lt;!-- =========================================================== --&gt;
      &lt;Set name="handler"&gt;
        &lt;New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"&gt;
          &lt;Set name="handlers"&gt;
           &lt;Array type="org.eclipse.jetty.server.Handler"&gt;
             &lt;Item&gt;
               &lt;New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/&gt;
             &lt;/Item&gt;
             &lt;Item&gt;
               &lt;New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/&gt;
             &lt;/Item&gt;
           &lt;/Array&gt;
          &lt;/Set&gt;
        &lt;/New&gt;
      &lt;/Set&gt;
  
      &lt;!-- =========================================================== --&gt;
      &lt;!-- extra server options                                        --&gt;
      &lt;!-- =========================================================== --&gt;
      &lt;Set name="stopAtShutdown"&gt;&lt;Property name="jetty.server.stopAtShutdown" default="true"/&gt;&lt;/Set&gt;
      &lt;Set name="stopTimeout"&gt;&lt;Property name="jetty.server.stopTimeout" default="5000"/&gt;&lt;/Set&gt;
      &lt;Set name="dumpAfterStart"&gt;&lt;Property name="jetty.server.dumpAfterStart" deprecated="jetty.dump.start" default="false"/&gt;&lt;/Set&gt;
      &lt;Set name="dumpBeforeStop"&gt;&lt;Property name="jetty.server.dumpBeforeStop" deprecated="jetty.dump.stop" default="false"/&gt;&lt;/Set&gt;
  
  &lt;/Configure&gt;
  </code></pre>
  
  <p>I'm quite new to Jetty and can't seem to find the answer online since all these files have been auto-generated so I'm not sure what I can delete and what not.</p>
  
  <p>Any ideas?</p>
  
  <p>(note: in my <code>/var/lib/jetty/start.d</code> only the <code>http.ini</code> is present (not sure if there should be a <code>https.ini</code>))</p>
  
  <p>My firewall status:</p>
  
  <pre><code>Status: active
  
  To                         Action      From
  --                         ------      ----
  Anywhere                   ALLOW       somesubnet/24
  22                         ALLOW       Anywhere
  300                        ALLOW       Anywhere
  3000                       ALLOW       Anywhere
  3001                       ALLOW       Anywhere
  3002                       ALLOW       Anywhere
  3003                       ALLOW       Anywhere
  80                         ALLOW       Anywhere
  443                        ALLOW       Anywhere
  8443                       ALLOW       Anywhere
  443/tcp                    ALLOW       Anywhere
  521                        ALLOW       Anywhere
  80,443/tcp                 ALLOW       Anywhere
  22 (v6)                    ALLOW       Anywhere (v6)
  300 (v6)                   ALLOW       Anywhere (v6)
  3000 (v6)                  ALLOW       Anywhere (v6)
  3001 (v6)                  ALLOW       Anywhere (v6)
  3002 (v6)                  ALLOW       Anywhere (v6)
  3003 (v6)                  ALLOW       Anywhere (v6)
  80 (v6)                    ALLOW       Anywhere (v6)
  443 (v6)                   ALLOW       Anywhere (v6)
  8443 (v6)                  ALLOW       Anywhere (v6)
  443/tcp (v6)               ALLOW       Anywhere (v6)
  521 (v6)                   ALLOW       Anywhere (v6)
  80,443/tcp (v6)            ALLOW       Anywhere (v6)
  
  443/tcp                    ALLOW OUT   Anywhere
  3000                       ALLOW OUT   Anywhere
  443/tcp (v6)               ALLOW OUT   Anywhere (v6)
  3000 (v6)                  ALLOW OUT   Anywhere (v6)
  </code></pre>
  
  <p>Docker command I used:</p>
  
  <pre><code>docker run -d --name=jetty -p 80:8080 -p 443:8443 -v /home/deploy/backend/my-server/target/my-server-0.0.1-SNAPSHOT.war:/var/lib/jetty/webapps/root.war -v /home/deploy/backend/ssl:/etc/ssl/private jetty
  </code></pre>
  
  <p>It runs fine on <code>http://my-server.com</code> but doesn't load at <code>https://my-server.com</code></p>