How can I modify the nginx configuration in Railway?
I'm getting a "413 Request Entity Too Large" when uploading images to my Laravel app deployed with Railway (which is using Nixpacks).
I think that this can be solved by modifying the "client_max_body_size 20M;" in in /etc/nginx/nginx.conf.
However, I can't figure out how can I access this configuration file Railway.
How can I make such a configuration in Railway?
15 Replies
Project ID:
49a4d477-fb25-4e0e-94a5-120cedd527f2
49a4d477-fb25-4e0e-94a5-120cedd527f2
Create a
nginx.template.config
file in the root of your application. Add the content as follows:
Reference:
https://nixpacks.com/docs/providers/php
https://github.com/railwayapp/nixpacks/blob/main/src/providers/php/nginx.template.conf
PHP | Nixpacks
App source + Nix packages + Docker = Image
GitHub
nixpacks/nginx.template.conf at main · railwayapp/nixpacks
App source + Nix packages + Docker = Image. Contribute to railwayapp/nixpacks development by creating an account on GitHub.
Thanks a lot for the support. This is a point in the right direction, but it's still not uploading the file. I figured out myself that the correct file name is nginx.template.conf and not .config, but now I have this error: "POST Content-Length of 9218627 bytes exceeds the limit of 8388608 bytes". I guess this should be modified in the php.ini file but, again, I can't see where I can modify that in Railway.
Finally I could change the php.ini configurations adding this code to the web.php file: Route::group(['middleware'=>'custom_middleware'], function () {
ini_set('upload_max_filesize', '5000M');
ini_set('post_max_size', '5000M');
});
Nevertheless, it's still not working as now it's showing the following error: " The "" file does not exist or is not readable."
I see that this could be related to the permissions of the temporary path that nginx is using to store large images as pointed here: https://github.com/laravel/framework/issues/31249
GitHub
The "" file does not exist or is not readable. · Issue #31249 · lar...
Laravel Version: 6.12.0 PHP Version: 7.2.0 Database Driver & Version: 10.1.35-MariaDB Description: I get this error: Symfony\Component\Mime\FileinfoMimeTypeGuesser::guessMimeType:50 vendor/symf...
But I cant see how to modify the permissions on this path (/var/lib/nginx/tmp/client_body) as pointed in the answers to the post
Apologies for giving the wrong file name.
It is unfortunate that modifying the
nginx.template.conf
did not work for you.
All the best.It worked! But it's still something missing there. I guess now the problem is related to the permissions of the temporary path that nginx uses to store the images.
Are you running Laravel 6?
No, I'm runing Laravel 9
9.52.7 to be exact
After many changes, I see that the code I added to change the value of 'upload_max_filesize' is not really changing the value in php.ini. How I can modify this value in Railway?
Try deploying your app using docker instead of Nixpacks.
I've been trying to do so, but I can't get the correct Dockerfile configuration. The template provided by Railway is missing the Dockerfile: https://github.com/railwayapp-templates/laravel
GitHub
GitHub - railwayapp-templates/laravel
Contribute to railwayapp-templates/laravel development by creating an account on GitHub.