From 6811378c3846e11e68746d9ca265b9cfa0e462f2 Mon Sep 17 00:00:00 2001 From: Maxime Pauvert Date: Fri, 29 Dec 2023 17:11:00 +0100 Subject: [PATCH 1/3] chore: add configure trusted proxy for laravel app --- content/guides/tutorial-laravel.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/content/guides/tutorial-laravel.md b/content/guides/tutorial-laravel.md index 1658fc4c7..d486ffa57 100644 --- a/content/guides/tutorial-laravel.md +++ b/content/guides/tutorial-laravel.md @@ -62,7 +62,7 @@ For example, if you launch the build with `npm run prod`: `CC_POST_BUILD_HOOK=np {{< readfile file="link-addon.md" >}} -## Configure your database +### Configure your database Make sure you have created a database add-on in the Clever Cloud console, and that it's linked to your application. When it's done, edit `config/database.php` to set the correct environment variable names (`MYSQL_ADDON_xxx` instead of `DB_xxx` for a mysql database). @@ -95,13 +95,13 @@ For instance for MySQL: If you want to have database migrations automatically run during each deployment, add this hook instruction to the application's [environment variables](#setting-up-environment-variables-on-clever-cloud) `CC_POST_BUILD_HOOK=php artisan migrate --force` -## Configure storage +### Configure storage Create a FS Bucket add-on and link it to your application. Note its host (you can see it from the addon configuration panel, or in the environment variables exported by the addon). It looks like `bucket-01234567-0123-0123-0123-012345678987-fsbucket.services.clever-cloud.com`. Create a new [environment variable](#setting-up-environment-variables-on-clever-cloud) called `CC_FS_BUCKET` and set `/storage/app:` as its value. -### Optional: configure task scheduling +### Optional: Configure task scheduling If your app uses [task scheduling](https://laravel.com/docs/scheduling), you need to configure a cron to run the scheduling process: @@ -130,6 +130,21 @@ If one of your scheduled tasks needs to allocate more memory than this limit, th To allow it to use more memory, you can call [`ini_set()`](https://www.php.net/manual/en/function.ini-set) inside a `php_sapi_name() === 'cli'` condition from an early hook to the app's lifecycle (like the `AppServiceProvider`). See [this Gist](https://gist.github.com/dsferruzza/e57dd3db957efe7a649325868f0024a4) for an example implementation. +### Optional: Configure trusted proxy + +To ensure Laravel correctly handles HTTP requests when using the Clever Cloud HTTP reverse proxy (Sōzu), add the following code to the `config/trustedproxy.php` file: + +```php + '*', +]; + +``` + +This configuration specifies that all proxies are trusted, allowing Laravel to seamlessly recognize HTTP requests in the presence of a proxy. + {{< readfile file="deploy-git.md" >}} {{< readfile file="deploy-ftp.md" >}} From 8bf0ae08893325a8b37b993ff2ebd6899bedd6a2 Mon Sep 17 00:00:00 2001 From: Maxime Pauvert Date: Fri, 29 Dec 2023 18:20:52 +0100 Subject: [PATCH 2/3] fix trusted proxy for laravel app Co-authored-by: David Sferruzza --- content/guides/tutorial-laravel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/tutorial-laravel.md b/content/guides/tutorial-laravel.md index d486ffa57..cb660c03d 100644 --- a/content/guides/tutorial-laravel.md +++ b/content/guides/tutorial-laravel.md @@ -138,7 +138,7 @@ To ensure Laravel correctly handles HTTP requests when using the Clever Cloud HT '*', + 'proxies' => env('CC_REVERSE_PROXY_IPS', ''), ]; ``` From bb4a46da95bf253ed131124528e557f1f1807523 Mon Sep 17 00:00:00 2001 From: Maxime Pauvert Date: Fri, 29 Dec 2023 18:23:54 +0100 Subject: [PATCH 3/3] fix trusted proxy for laravel app --- content/guides/tutorial-laravel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/tutorial-laravel.md b/content/guides/tutorial-laravel.md index cb660c03d..557e6def2 100644 --- a/content/guides/tutorial-laravel.md +++ b/content/guides/tutorial-laravel.md @@ -138,7 +138,7 @@ To ensure Laravel correctly handles HTTP requests when using the Clever Cloud HT env('CC_REVERSE_PROXY_IPS', ''), + 'proxies' => env('CC_REVERSE_PROXY_IPS'), ]; ```