Report this

What is the reason for this report?

Unsure if Droplet has a HTTP upload limit 413 Request Entity Too Large error in POST requests

Posted on May 30, 2023

I am unsure where the issue lies (so this question might not be particular to DigitalOcean droplets). I am uploading multipart/form-data via a POST request from axos npm package, payload looks something like ::

Form Data
1.  file:
    (binary)

2.  file:
    (binary)

3.  file:
    (binary)

4.  file:
    (binary)

5.  file:
    (binary)

6.  file:
    (binary)

7.  file:
    (binary)

8.  file:
    (binary)

9.  file:
    (binary)

10.  file:
    (binary)

11.  file:
    (binary)

12.  file:
    (binary)

13.  file:
    (binary)

14.  file:
    (binary)

15.  file:
    (binary)

16.  file:
    (binary)

17.  file:
    (binary)

18.  file:
    (binary)

19.  file:
    (binary)

I have a DO Droplet 2 GB Memory / 50 GB Disk / LON1 - Ubuntu 22.10 x64 . Currently runs as a proxy server to another server. It runs Ubuntu, Nodejs (Express) server, very simple server ::

// include dependencies
const express = require('express');
const { createProxyMiddleware } = require('http-proxy-middleware');

// proxy middleware options
/** @type {import('http-proxy-middleware/dist/types').Options} */
const options = {
  target: 'http://example.com', // target host
  changeOrigin: true, // needed for virtual hosted sites
  ws: true, // proxy websockets
  pathRewrite: {
    '^/api/log-handler': '/' // rewrite path
  },
  router: {
    // when request.headers.host == 'dev.localhost:3000',
    // override target 'http://www.example.org' to 'http://localhost:8000'
    'dev.localhost:3000': 'http://localhost:8000',
  },
};

// create the proxy (without context)
const exampleProxy = createProxyMiddleware(options);

// mount `exampleProxy` in web server
const app = express();

app.use(express.json({ limit: '500mb' }));
app.use(express.urlencoded({ extended: false, limit: '500mb', parameterLimit: 500000 }));

app.use('/api', exampleProxy);
app.listen(3000);

You can see above, I have tried to increase the size of requests within express…

Also within my nginx config /etc/nginx/nginx.conf I have added ::

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

          client_max_body_size          500M;
  client_body_buffer_size       128k;
  keepalive_timeout             65;
  tcp_nodelay                   on;

I’ve added the client_max_body_size in the /etc/nginx/sites-available/default and /etc/nginx/sites-available/example.com files too just to make sure.

However, on upload i’m still getting this error in the browser window…

Status413
Request Entity Too Large
VersionHTTP/1.1
Transferred268 B (67 B size)
Referrer Policystrict-origin-when-cross-origin
Request PriorityHighest

In the response headers of the network tab I see this…

Connection:
keep-alive

Content-Length:
67

Content-Type:
text/html

Date:
Tue, 30 May 2023 17:10:33 GMT

Server:
nginx/1.22.0 (Ubuntu)

X-Powered-By:
Express

Since this server is a proxy to another server, I assume the error lies with the express server, since the response headers tell me the server is nginx etc and my server that this DO droplet forwards the request too isn’t an nginx server.

My question does DO droplets have a limit on http uploads that I might be hitting? Is the error coming from the nginx/nodejs server? Or is it coming from the server -> that the request gets forwarded to (from what I can see there’s no request to that server so the request doesn’t get there but I don’t know it could get eaten up before it gets to the console.log outputs).

Thank you, any advice is super helpful too.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.