Created
January 18, 2017 01:00
-
-
Save gabrielkoerich/b7532a31c3894e2de9e55a3f54681fd4 to your computer and use it in GitHub Desktop.
Revisions
-
Gabriel Koerich renamed this gist
Jan 18, 2017 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,6 @@ use App; use Closure; class ConfigureCloudFlare { -
Gabriel Koerich created this gist
Jan 18, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ <?php namespace App\Http\Middleware; use App; use Closure; use Exception; class ConfigureCloudFlare { /** * Set the CloudFlare conneting IP and https if applied. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (! App::environment('production')) { return $next($request); } if ($request->server->has('HTTP_CF_CONNECTING_IP')) { if ($request->isSecure()) { $request->server->set('HTTPS', true); } $request->server->set('REMOTE_ADDR', $request->server->get('HTTP_CF_CONNECTING_IP')); } return $next($request); } }