Created
January 18, 2017 01:00
-
-
Save gabrielkoerich/b7532a31c3894e2de9e55a3f54681fd4 to your computer and use it in GitHub Desktop.
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 characters
| <?php | |
| namespace App\Http\Middleware; | |
| use App; | |
| use Closure; | |
| 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); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment