diff --git a/config/laravels.php b/config/laravels.php index 33d26f18..c5fcd88a 100644 --- a/config/laravels.php +++ b/config/laravels.php @@ -93,6 +93,18 @@ 'laravel_base_path' => env('LARAVEL_BASE_PATH', base_path()), + /* + |-------------------------------------------------------------------------- + | HTTP Force SSL + |-------------------------------------------------------------------------- + | + | With this set, Swoole Server will place the header "Scheme", used by + | laravel to define routes through the application. This is important if + | you are using Swoole alone (not using nginx/apache proxy). + | + */ + 'http_force_ssl' => env('LARAVELS_HTTP_FORCE_SSL', false), + /* |-------------------------------------------------------------------------- | Inotify Reload diff --git a/src/Swoole/Request.php b/src/Swoole/Request.php index 7d309af0..9d9070be 100644 --- a/src/Swoole/Request.php +++ b/src/Swoole/Request.php @@ -55,6 +55,14 @@ public function toIlluminateRequest(array $rawServer = [], array $rawEnv = []) } } $server = array_change_key_case($server, CASE_UPPER); + + if ( + config('laravels.http_force_ssl', false) + && !isset($server['REQUEST_SCHEME']) + ) { + $server['REQUEST_SCHEME'] = 'https'; + } + $_SERVER = array_merge($_SERVER, $server); if (isset($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] === 'https') { $_SERVER['HTTPS'] = 'on';