Play Framework 2 HTTP to HTTPS redirect

Jan 9, 2014 • Mike Seid

One good feature of Play Framework is that it doesn’t require an HTTP server in front of it. Play runs netty under the hood and it takes care of the HTTP service. Unfortunately, the play team decided not to support HTTPS currently. So I am using an Amazon ELB (Elastic Load Balancer) to both balance my servers and terminate the HTTPS connections.

The feature I wanted was to forward all requests from HTTP to HTTPS. This can be done simply by taking advantage of a header set by the ELB and using the Global.scala object.