Enforce HTTPS in playframework

Hello,

I am using Play 2.6 version and in order to redirect all HTTP requests to HTTPS automatically, I have added following lines in application.conf file:

play.filters.enabled += play.filters.https.RedirectHttpsFilter
play.filters.https.strictTransportSecurity="max-age=31536000; includeSubDomains"

However, when entering www.mywebsite.com in my browser, it does not automatically redirect to https://.

Am I missing something ? Is there some extra configuration which needs to be set ?

You could be missing a lot of things. Do you have a certificate?

Note: The common (best?) practice is to use a proxy, something like nginx in front of your application for things like TLS, rate limiting, forwarding, etc.

Yes, I do have a certificate (I am using Let's encrypt) and https://www.mywebsite.com works just fine. However if I put simply www.rateneighbor.com, it does not automatically redirect to https and it serves from plain http

I am using clever-cloud.com as PaaS provider and as per them ‘’ You just have to check the standard proxy HTTP headers’’.

I managed to make it work by using this approach: https://gist.github.com/urcadox/a54c20f0b86f1e9d36a341c861efd2dd

Maybe there are some better approaches ?