strapi增加上传文件大小nginx

Strapi increase upload file size nginx

我无法在 Strapi 中增加文件上传大小。我找到了一些关于它的文档:https://strapi.io/documentation/v3.x/plugins/upload.html#configuration 但我没有确切地看到我需要更新它的地方 (Strapi v3.0.1)。我通过 Docker.

在 nginx 后面使用它

我的 nginx 配置:

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;
        }

    }

还有我的 docker-compose 文件:

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"

我在我的 strapi 应用程序上没有看到任何 plugins 文件夹,我创建了一个文件 /config/request.json,其中包含以下内容:

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

但是当我尝试上传任何文件时,我得到一个 413 Request Entity Too Large 来自 nginx 的消息。

有什么想法吗?

已解决!错误在不同的容器中。我正在使用 https://github.com/nginx-proxy/nginx-proxy 来提供一种简单的方法来编排 letsencrypt 和不同的容器,我必须添加一个自定义图像来为 client_max_body_size 属性:

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