title: Redirect http request to https (spray io/scala)
body: <p>How do I redirect my <code>http</code> requests to <code>https</code>? Though this has been a common question, I don't see any solution for <code>spray io</code>.</p>
  
  <ul>
  <li>I have enabled ssl using Apache <code>CamelSslConfiguration</code> which works just fine.</li>
  <li>I have setup port forwarding (iptables) from 80 -> 8081 and 443 -> 8081</li>
  </ul>
  
  <p>Below is my Boot.scala file</p>
  
  <pre><code>object Boot extends App with CamelSslConfiguration with ApiScheduler {
  
    // we need an ActorSystem to host our application in
    implicit val system = ActorSystem("on-spray-can")
  
    // create and start our service actor
    val service = system.actorOf(Props[ApiServiceActor], "api-service")
  
    implicit val timeout = Timeout(50.seconds)
    // start a new HTTP server on port 8080 with our service actor as the handler
    IO(Http) ? Http.Bind(service, interface = "0.0.0.0", port = 8081)
  }
  </code></pre>