Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fly launch for Laravel 11 fails #3371

Open
edjw opened this issue Mar 14, 2024 · 2 comments
Open

fly launch for Laravel 11 fails #3371

edjw opened this issue Mar 14, 2024 · 2 comments

Comments

@edjw
Copy link

edjw commented Mar 14, 2024

This line in the Dockerfile for Laravel stops fly launch running for the recently-released Laravel 11. Commenting out this line in the Dockerfile allows a Laravel 11 app to launch on fly

&& sed -i 's/protected \$proxies/protected \$proxies = "*"/g' app/Http/Middleware/TrustProxies.php \

Laravel 11 changed where the config is for trusting all proxies. app/Http/Middleware/TrustProxies.php doesn't exist any more.

This is how to trust all proxies in Laravel 11:
https://laravel.com/docs/11.x/requests#trusting-all-proxies

Adding the code below in bootstrap/app.php seems to be what to do but I am very very new to Laravel

    ->withMiddleware(function (Middleware $middleware) {
        $middleware->trustProxies(at: '*');
    })
@eznix86
Copy link

eznix86 commented Mar 15, 2024

Replace this line below in your dockerfile, from:

&& sed -i 's/protected \$proxies/protected \$proxies = "*"/g' app/Http/Middleware/TrustProxies.php \

to this:

&& sed -i '/->withMiddleware(function (Middleware \$middleware) {/a\
    \$middleware->trustProxies(at: "*");' bootstrap/app.php \

@KTanAug21
Copy link
Contributor

Hello @edjw and @eznix86 !

Thank you for reporting this issue and suggesting a fix for this! Great job!

A new pre-release version of the flyctl command has been rolled out with the proper changes for setting Trusted Proxies for a Laravel 11 application. It will be included in the next major release for flyctl, but the pre-release is installable of course! Alternately, you can make use of the dockerfile-laravel package to generate Dockerfile supporting Laravel 11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants