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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Hey @capb994,
The “413 Request Entity Too Large” error message is coming from your Nginx server. It is not from DigitalOcean or your Express.js server. This error is usually thrown when the size of the HTTP request (i.e., the data being sent in the request body) exceeds the
client_max_body_size
directive in the Nginx configuration.To answer your other question, no DigitalOcean wouldn’t be restricting or limiting such uploads.
Location of the Directive: If
client_max_body_size
is defined in different places in your Nginx configuration, the one defined in the most specific context will be used. For instance, if it’s defined in thehttp
context and also in aserver
context, theserver
context will be used. Make sure you’re defining it in the right place.The Other Server: If the request is being proxied to another server, it’s possible that the error is coming from that server. You should check the configuration of the other server to make sure it’s also able to handle large request bodies.