Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect HTTP requests to HTTPS on Google App Engine and Play Framework

I'm using flexible environment on Google App Engine to run web app written in Scala and Play Framework. I've added custom domain to my application and now my app is available both through http and https. But I need to make redirection from http to https. I've tried to manage it by doing the following, but it didn't work:

application.conf:

play.http.filters = "controllers.Filters"

controllers.Filters:

import javax.inject.Inject

import play.api.http.DefaultHttpFilters
import play.filters.cors.CORSFilter
import play.filters.https.RedirectHttpsFilter

class Filters @Inject() (corsFilter: CORSFilter, redirectHttpsFilter: RedirectHttpsFilter) extends DefaultHttpFilters(corsFilter, redirectHttpsFilter)

UPD Maybe the problem is that I need to specify https port in my Dockerfile? Here is a Dockerfile:

FROM gcr.io/google_appengine/openjdk
RUN wget http://downloads.lightbend.com/scala/2.11.8/scala-2.11.8.deb
RUN dpkg -i scala-2.11.8.deb
RUN wget https://dl.bintray.com/sbt/debian/sbt-0.13.13.deb
RUN dpkg -i sbt-0.13.13.deb
RUN apt-get update
RUN apt-get install scala sbt
RUN rm -f scala-2.11.8.deb
RUN rm -f sbt-0.13.13.deb
ADD . /appname
WORKDIR /appname
RUN chmod 755 ./docker-entrypoint.bash
ENTRYPOINT ["./docker-entrypoint.bash"]
CMD ["./target/universal/stage/bin/appname", "-Dhttp.port=8080"]
like image 963
alex Avatar asked Oct 31 '17 09:10

alex


1 Answers

May be you have to write another tiny application, listening on http port and issuing Location header to any incoming request?

like image 102
mickvav Avatar answered Oct 18 '22 03:10

mickvav