I have a laravel app running with php-fpm on docker. I use fastcgi_proxy to pass requests to the fpm container. When I build some frontend, my static files(css, js, photos) that are saved under the public directory, are not loading. Laravel returns 404(it's not nginx's 404) what's the solution?
p.s: my laravel app is mounted using a volume. All of the access rights are the same and the APIs are working correctly. Just asset files are failing.
Thanks in advance
How are you trying to access the static files
If it’s in public folder as a static asset you can call it directly of course. You need a directive for static files in nginx There’s many articles for that. Check this one for Wordpress https://wordpress.org/support/article/nginx/
still the same...
I would remove laravel completely and see if it serves static assets like jpg or txt
Laravel is behind a "fastcgi_proxy" and it's inside a fpm docker container. Nginx is on the OS itself. It's laravel giving the 404 not Nginx.
Static assets are not supposed to be served by laravel Instead, nginx serving them directly from public folder
Think about it. All laravel knows is what’s in its routes Public assets don’t exist for laravel When you run locally, your php server does serve static assets In production, it’s nginx job to serve static assets
Ok so I'll have to write some location block to resolve the assets from the mounted volume?
Yeah I guess this is a question for docker expert I guess (I’m not)
Обсуждают сегодня