The large attachment upload is blocked at 413, why is it not understandable in the browser?
When uploading a large attachment, it is blocked by the gateway and returns 413. The reason it is not understandable in the browser is that this restriction has already taken effect before the request enters the application: The layer that acts as the reverse proxy reads the size in the request header to decide whether to allow or not. The program has no chance to take over this request, so it cannot return a unified error message format within the site. What users often see is a blank page or a prompt without context, rather than 'which file is over the limit'.
Which part does the upper limit control?
It manages the volume of the entire request body, not the size of a single file. When attachments, fields, and tokens are included in the form at the same time, these contents are merged for calculation, so it is often the case that other fields exceed the volume and cause the blockage.
The default value given by the reverse proxy layer is not high, the corresponding directive of nginx is set to one megabyte by default, and can be overridden at three levels: the whole site, a single site, and a single position. That is to say, the upload entrance and interface entrance in the same site can have different upper limits, and it is more stable to configure separately according to the entrance than to increase the whole site.
Why the error cannot be read in the browser
An exceeded limit response is directly given by the proxy layer, usually without the station's page template and not going through the front-end error handling branch. The front-end script waits for a structured return, but receives a minimal response instead, resulting in a stuck progress bar, missing prompts, or continuously displaying uploading.
To make it readable, it needs to be coordinated at two places: first, the front-end needs to do local volume verification before submission, blocking excessive requests before initiating the request; second, the application layer outside the proxy layer also needs to have its own limit, the relationship between the two levels of limits is that 'the application layer is not higher than the proxy layer', otherwise excessive requests will first enter the program and then be rejected by internal rules, and the error message will finally have an in-site format.
How to check the three types of upload entries within the site
| Entry | Common volume | Where to configure the limit | Verification method |
|---|---|---|---|
| Background attachment upload | Single image and document | The proxy layer is opened separately according to the upload path | Try once with a real file close to the limit |
| Batch import | Zip file and table | Release the entire proxy layer, control the program side by item count | Run one ZIP and one Excel file separately |
| Upload attachments through the interface | File content encoded in base64 | Check both the program and the proxy | Pay attention to the volume increase caused by encoding |
The batch import within the site supports compressed packages and spreadsheet formats. Such requests are large in volume and time-consuming, and it is common to encounter the situation where the page can be uploaded but the interface cannot when only one limit is adjusted. Moreover, when uploading attachments through the interface, the file content is placed in the request body in base64 encoding format, which itself causes volume expansion, and it is easy to underestimate the limit when estimated based on the original file size.
There is also an easy-to-miss place during deployment.
The program listens to port 8001 by default, which is usually forwarded by a reverse proxy. When deploying, make sure that the forwarding section of the proxy is also subject to the same upper limit constraint: when there are multiple proxy layers, each layer must be opened up, and only changing the outermost layer will cause the network environment to change from good to bad. Similarly, timeout and volume are two types of parameters, adjusting only the volume and not the timeout will still cause large attachments to break off during transmission.
Common questions
Is it okay to change only one upper limit?No, proxy layer, application layer, and front-end verification are three places, and only releasing one will move the error to a worse-to-read position.
Why is it still failing after changing it?First, check if it is a timeout issue and not a volume issue; then see if the request has gone through multiple proxies; finally, verify if the interface and page are using the same configuration.
Should the upload limit for images and attachments be the same?It is more reasonable to separate them, with the upper limit for regular images low, and the upper limit for attachments and import packages high, covering them by path is safer than the entire site.
What should be paid attention to when uploading encoded content?The request body after encoding is larger than the original file, leave some margin when estimating, and distinguish in the log between 'blocked by proxy' and 'rejected by the program'.