From ff5b6f5eec86b6d64bb7e58f7f95ee59843eb57d Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 9 May 2026 07:41:52 -0600 Subject: [PATCH] Fix file upload limit over 2MB in production with HTTPS - Use printf instead of echo to correctly write php.ini with newlines (Alpine ash echo does not interpret \n, leaving the file malformed and PHP falling back to its 2MB default) - Add nginx.conf with client_max_body_size 25M as front-end proxy - Start nginx on port 8080 via supervisord; move artisan serve to internal port 8081 so nginx can proxy requests with proper limits Co-Authored-By: Claude Sonnet 4.6 --- Dockerfile | 3 ++- nginx.conf | 28 ++++++++++++++++++++++++++++ supervisord.conf | 7 ++++++- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 8e4c38c7..5e524c15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,8 +17,9 @@ RUN mkdir -p storage/framework/{sessions,views,cache} \ RUN php artisan storage:link -RUN echo "upload_max_filesize=20M\npost_max_size=25M" > /app/php.ini +RUN printf "upload_max_filesize=20M\npost_max_size=25M\n" > /app/php.ini +COPY nginx.conf /etc/nginx/nginx.conf COPY supervisord.conf /etc/supervisord.conf EXPOSE 8080 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..8451a748 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,28 @@ +worker_processes auto; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + + client_max_body_size 25M; + proxy_read_timeout 120s; + proxy_send_timeout 120s; + + server { + listen 8080; + + location / { + proxy_pass http://127.0.0.1:8081; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + } +} diff --git a/supervisord.conf b/supervisord.conf index f2c97404..47ef7804 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -1,8 +1,13 @@ [supervisord] nodaemon=true +[program:nginx] +command=nginx -g "daemon off;" +autostart=true +autorestart=true + [program:laravel] -command=php -c /app/php.ini /app/artisan serve --host=0.0.0.0 --port=8080 +command=php -c /app/php.ini /app/artisan serve --host=127.0.0.1 --port=8081 autostart=true autorestart=true