Search code examples
strapi

Strapi increase upload file size nginx


I am not able to increase the file upload size in Strapi. I found some documentation about it: https://strapi.io/documentation/v3.x/plugins/upload.html#configuration but I don't see exactly where I need to update that (Strapi v3.0.1). I am using it behind nginx through Docker.

My nginx configuration:

server {
        listen 80;
        server_name api.domain.dev;
        client_max_body_size 2048M;
        location / {
            proxy_read_timeout 3600;
            proxy_set_header Host $http_host;
            proxy_pass http://docker-api;
        }

    }

And my docker-compose file:

api:
    image: strapi/strapi
    restart: unless-stopped
    env_file: .env
    environment:
      DATABASE_CLIENT: ${DATABASE_CLIENT}
      DATABASE_NAME: ${DATABASE_NAME}
      DATABASE_HOST: ${DATABASE_HOST}
      DATABASE_PORT: ${DATABASE_PORT}
      DATABASE_USERNAME: ${DATABASE_USERNAME}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}
      NODE_ENV: production
    volumes:
      - ./api:/srv/app
    expose:
      - "1337"
      - "3500"

I don't see any plugins folder on my strapi app, I've created a file /config/request.json with the following content:

{
  "parser": {
    "enabled": true,
    "multipart": true,
    "formidable": {
      "maxFileSize": 2000000000
    }
  }
}

But when I try to upload any file I get a 413 Request Entity Too Large message comming from nginx.

Any idea?


Solution

  • Solved! The error was in a different container. I'm using https://github.com/nginx-proxy/nginx-proxy to provide an easy way to orchestrate letsencrypt and the different containers, I had to add a custom image to provide a custom value for the client_max_body_size property:

    FROM jwilder/nginx-proxy
    RUN { \
          echo 'server_tokens off;'; \
          echo 'client_max_body_size 2048M;'; \
        } > /etc/nginx/conf.d/my_proxy.conf