Skip to content

Instantly share code, notes, and snippets.

@peppeocchi
Last active November 3, 2017 08:53
Show Gist options
  • Save peppeocchi/4f522663d7e88029daeba833c835df3d to your computer and use it in GitHub Desktop.
Save peppeocchi/4f522663d7e88029daeba833c835df3d to your computer and use it in GitHub Desktop.
Laravel middleware for Elastic Beanstalk (HTTPS and Load balancer)
<?php namespace App\Http\Middleware;
use Closure;
/**
* Put this file in app/Http/Middleware
* Read more here https://github.com/peppeocchi/laravel-elb-middleware
*
*/
class ElasticBeanstalkHttps
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$request->setTrustedProxies(['127.0.0.1', $request->server->get('REMOTE_ADDR')]);
return $next($request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment