0
基于this我在应用中添加了与重定向循环结果相同的中间件。Laravel 5中间件https aws ec2重定向循环
如果用户未通过身份验证,应用程序会重定向到登录页面,因此对于我来说,这看起来就是问题所在。或者可能不是。
ssl证书安装正确,它的工作原理(如果我手动去https://myapp.org它按预期工作)。
主要问题是,我使用整个应用程序的助手网址()生成的网址,现在我需要重定向到安全的网址。我尝试删除该中间件,并将重定向添加到.htaccess但结果是相同的(该网页有一个重定向循环)。
UPDATE 我试图调试该问题,看起来像没有重定向到https,这就是为什么重定向循环。我添加日志标题....
{
"host": [
"myapp.org"
],
"accept": [
"text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,*\/*;q=0.8"
],
"user-agent": [
"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/41.0.2272.76 Safari\/537.36"
],
"accept-encoding": [
"gzip, deflate, sdch"
],
"accept-language": [
"en-US,en;q=0.8"
],
"cookie": [
"XSRF-TOKEN=..."
],
"x-forwarded-for": [
"IP ADDRESS"
],
"x-forwarded-host": [
"myapp.org"
],
"x-forwarded-server": [
"ip-IP.compute.internal"
],
"connection": [
"Keep-Alive"
]
}
我也登录的$request->secure()
的价值,它总是假的。
这是我的中间件(日志的结果是在每个日志行旁边评论)
<?php namespace App\Http\Middleware;
use Closure;
use Log;
class HttpsProtocol
{
/**
* Redirect to https.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
if(!$request->secure() && app()->environment() === 'production') {
Log::info(app()->environment()); // "production"
Log::info($request->secure()); // ""
Log::info($request->header('x-forwarded-proto')); // ""
Log::info(json_encode($request->header())); // The json just posted
Log::info($request->getRequestUri()); // "/auth/login"
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
}
我的应用程序是在弹性魔豆(EC2单实例)。 任何帮助,将不胜感激,谢谢。
我发现这里的解决方案 http://stackoverflow.com/questions/20363051/aws-elasticbeanstalk-single-instance-force-ssl-redirect-loop – peppeocchi 2015-03-13 15:40:12
的感谢!我一直试图弄清楚这一点。 – 2015-04-24 20:30:51