Trying to enable Https in play framework

188 views
Skip to first unread message

newbiePlay

unread,
Dec 10, 2015, 11:39:50 PM12/10/15
to play-framework

I want to enable https in play in the dev mode.

I have done the following
1. generated the ssl certificates using open ssl and added certificates and key  to the conf folder of the play project
2.  app.conf looks like this
      play.crypto.secret = "changeme"
play.i18n.langs = [ "en" ]
include "securesocial.conf"
application.mode=dev
http.port=9000
https.port=9443

3. Securesocial.conf looks like this 

   securesocial {
onLoginGoTo=/

  onLogoutGoTo=/login

  
  ssl=true

  cookie {
    #name=id
    #path=/
    #domain=some_domain
    #httpOnly=true
    #idleTimeoutInMinutes=30
    #absoluteTimeoutInMinutes=720
  }

}


Please help me out on this.


Maxim Valyanskiy

unread,
Dec 11, 2015, 12:27:36 AM12/11/15
to play-framework
Hello!

HTTPS can't be configured via config file. Use "-Dhttps.port=9443" command line option.

Maxim

пятница, 11 декабря 2015 г., 7:39:50 UTC+3 пользователь newbiePlay написал:

Matthias Kurz

unread,
Dec 11, 2015, 6:10:48 AM12/11/15
to play-framework
HTTPS actually CAN be configured via config file (at least in Play 2.4).
In application.conf:
play.server.http.address=127.0.0.1
play.server.http.port=9000
play.server.https.address=127.0.0.1
play.server.https.port=9443

But be aware: This will only works in prod mode (deploying Play with "activator stage", "activator dist", etc.) but not in developing mode.

For developing mode you have to use "activator -Dhttp.port=9443" and "... -Dhttps.port=9443" on the command line like Maxim described.

Starting with Play 2.5 (not released yet) you will also be able to set the ports for development mode by adding
PlayKeys.devSettings := Seq("play.server.http.port" -> "9000")
PlayKeys.devSettings := Seq("play.server.https.port" -> "9443")
in your build.sbt (not the application.conf!)

Conclusio: With Play 2.5 you will be able to set the production ports in application.conf and the development ports in build.sbt. For now you have to use the command line options for dev mode.

Regards,
Matthias
Reply all
Reply to author
Forward
0 new messages