在Play上强制执行SSL!骨架 [英] Enforce SSL on Play! Framework

查看:120
本文介绍了在Play上强制执行SSL!骨架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Play! 1.2.2及其新的Netty客户端框架。

I'm currently using Play! 1.2.2 and its new Netty client framework.

我没有找到一种直接的方法来强制执行SSL,尽管可以让HTTP和HTTPS异步服务。有没有人与Play合作过!有一个直接的方法来执行SSL?不确定我是否需要创建重定向,或者是否可以在 conf 文件中快速解决此问题。

I haven't found a straightforward method to enforce SSL, although can get HTTP and HTTPS to serve asynchronously. Does anyone that's worked with Play! have a straightforward method of enforcing SSL? Not sure if I need to create redirects or if this can be solved quickly in a conf file.

推荐答案

有几种方法可以强制执行SSL。

There are a couple of ways to enforce SSL.

首先,您可以设置所有操作以使用 .secure()方法,例如

Firstly, you can set all your actions to use the .secure() method, for example

<a href="@{Application.index.secure()}">index page</a>

或者,可能最好的方法是通过前端HTTP服务器(如Apache)执行此操作,Nginx或Lighttpd。

Alternatively, and probably the best way, is to do this via a frontend HTTP server, such as Apache, Nginx or Lighttpd.

前端http服务器的想法是,您的应用程序在端口9000上运行,但无法从外部网络访问。 HTTP负责所有传入请求,并配置为仅接受HTTPS。 HTTPS由HTTP服务器处理,然后请求转发到Play。

The idea of the frontend http server, is that your application runs on port 9000, but is not accessible from the outside network. HTTP is responsible for all incoming requests, and is configured to only accept HTTPS. The HTTPS is handled by the HTTP server, and the request is then forwarded on to Play.

这使得整个Play应用程序正常工作,并且SSL被卸载另一个应用程序。

This leaves your entire Play application to work as normal, and the SSL is offloaded to another application.

这个方法可以应用于负载均衡器,而不是HTTP服务器,但我猜大多数人都会选择更便宜的替代方案HTTP服务器,除非在公司环境中运行。

This same method can be applied to a load balancer, rather than HTTP server, but I am guessing the majority of people will go with the far cheaper alternative of a HTTP server, unless running in a corporate environment.

这篇关于在Play上强制执行SSL!骨架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆