CERT-Polska/mwdb-core

[Question] mwdb-web complains about too large body but max_upload_size isn't set to anything

Closed this issue · 3 comments

I'm trying to upload large files (100mb+) through /upload and mwdb-web is reporting back status code 413 with the following log message

2024/03/14 19:15:42 [error] 12#12: *209 client intended to send too large body: 88220262 bytes, client: X.X.X.X, server: mwdb-web, request: "POST /api/file HTTP/1.1", host: "xyz.xyz", referrer: "https://xyz.xyz/upload"
"POST /api/file HTTP/1.1" 413 585 "https://xyz.xyz/upload" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" "X.X.X.X, X.X.X.X"

I've read #756 and I haven't included any related configurations related to "max_upload_size / MAX_UPLOAD_SIZE", so I'm trying to figure out how can I increase the file upload size limitation.

Thanks.

Hi,

Another upload size limitation you're hitting is introduced by default Nginx configuration used in mwdb-web Docker image:

I think this parameter should be somehow parametrized by env variables. nginx Docker base image already supports it by applying envsubst on template and it's already used for injecting correct PROXY_BACKEND_URL into configuration.

Right now, the only possible workaround is to build own Docker image using modified copy of nginx.conf.template with higher client_max_body_size:

FROM dr.cert.pl/dockerhub-proxy/certpl/mwdb-web:v2.12.0
COPY nginx.conf.template /etc/nginx/conf.d/default.conf.template

Thanks @psrok1

to further enhance, we have added the following nginx.conf like so below:

server {
    listen 80;
    server_name mwdb-web;
    root /usr/share/nginx/html;

    client_max_body_size 0;
    client_body_timeout 600s;
    send_timeout 600s;

    location /api/ {
        proxy_pass ${PROXY_BACKEND_URL}/api/;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_read_timeout 600s;
        proxy_connect_timeout 600s;
    }

    location = /api {
        absolute_redirect off;
        return 301 /api/;
    }

    location / {
        try_files $uri /index.html =404;
    }
}

I've added env var support in our nginx.conf.template. I also found that our nginx.conf.template is placed in a bit different path than nginx:stable entrypoint expects. If you want to use newer images that includes changes from #930, remember to change the path of nginx.conf.template as follows:

FROM dr.cert.pl/dockerhub-proxy/certpl/mwdb-web:master
- COPY nginx.conf.template /etc/nginx/conf.d/default.conf.template
+ COPY nginx.conf.template /etc/nginx/templates/default.conf.template