title: Jetty 9.2.1 redirect http to https
body: <p>can someone help migrating the code from jetty 8 to 9.2.1.</p>
  
  <p>I need to have jetty listening on port 80 (http) and redirect every request to 443 (https).</p>
  
  <p>this is the code for jetty 8, but it doesn’t work on 9.2.1. Version 9 uses ServerConnector but I cant find examples on how to use the <strong>setConfidentialPort</strong> property.</p>
  
  <pre><code>Server server = new Server();
  
  //Create a connector on port 80 to listen for HTTP requests
  SelectChannelConnector httpConnector = new SelectChannelConnector();
  httpConnector.setPort(80);
  server.addConnector(httpConnector);
  
  //Create a connector on port 443 to listen for HTTPS requests
  SslSocketConnector httpsConnector = new SslSocketConnector();
  httpsConnector.setPort(443);
  httpsConnector.setKeystore("name_of_the_keystore");
  httpsConnector.setPassword("password_for_the_keystore");
  httpsConnector.setKeyPassword("password_for_the_key");
  server.addConnector(httpsConnector);
  
  //Redirect the HTTP requests to HTTPS port
  httpConnector.setConfidentialPort(443);
  </code></pre>