Enforce HTTPS with Embedded Jetty on Heroku

荒凉一梦 提交于 2019-12-08 19:20:31

You need to check the x-forwarded-proto header to see if the request was secure:

Boolean secure = false;
if (request.headers.get("x-forwarded-proto") != null) {
  secure = request.headers.get("x-forwarded-proto").values.contains("https");
}
System.out.println("secure = " + secure);

I have checked with Heroku (maybe I miss here a version, and buildpack ,and so on ) but definitely you got none of this information:

  • a X-Forwarded-Proto point to http
  • a HttpServletRequest#scheme returns a http
  • a HttpServletRequest#secure return false ....
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!