Created
July 30, 2023 02:19
-
-
Save Rene-Roscher/f802c64c0346271335c2e11743909f2f to your computer and use it in GitHub Desktop.
Laravel Cloudflare-Proxy
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
| class AppServiceProvider extends ServiceProvider | |
| { | |
| /** | |
| * Bootstrap any application services. | |
| * | |
| * @return void | |
| */ | |
| public function boot() | |
| { | |
| if (\App::environment('production')) { | |
| $this->app['request']->server->set('HTTPS', true); | |
| URL::forceScheme('https'); | |
| } | |
| } | |
| } |
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 | |
| /** | |
| * Laravel - A PHP Framework For Web Artisans | |
| * | |
| * @package Laravel | |
| * @author Taylor Otwell <taylor@laravel.com> | |
| */ | |
| define('LARAVEL_START', microtime(true)); | |
| if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { | |
| $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; | |
| $_SERVER['HTTP_X_FORWARDED_FOR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; | |
| } |
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 | |
| use Illuminate\Http\Middleware\TrustProxies as Middleware; | |
| use Illuminate\Http\Request; | |
| class TrustProxies extends Middleware | |
| { | |
| /** | |
| * The trusted proxies for this application. | |
| * | |
| * @var array|string|null | |
| */ | |
| protected $proxies = '*'; | |
| /** | |
| * The headers that should be used to detect proxies. | |
| * | |
| * @var int | |
| */ | |
| protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment