Rejected upload returns 413, modify program limit first or modify gateway limit first

📅 October 10, 2026 👁️ 13

When an attachment upload is rejected and returns 413, should you first modify the limit in the program or the limit at the gateway layer? Modify the gateway layer first. The 413 status code is the entry layer response for 'request body too large'—the gateway stops reading the request header and body at that point, and the request never reaches the program. No matter how wide the limit in the program is, it won't take effect. You can refer to the original text in the gateway document: The default limit for the request body is one megabyte, and when the size of the request exceeds the configured value, the 413 status code is returned to the client, and the document explicitly states that the browser cannot correctly display this error.

What layer does the 413 indicate that the request stopped at?

Stop at the 'Read Request' layer. Common layers at this level include: the reverse proxy in front of the site, CDN or edge node, gateway configuration at the container entry, and the rules configured for the site in the panel.

There are two criteria for judgment. One is the response source: 413 returned by whom, where the log falls - there is no such request in the program access log, which means it is intercepted at the entry layer. The other is the error body form: the entry layer returns its own default error page, which is different in style from the error page within the program.

Check these two before making any configuration changes. Skipping this step and directly modifying the program restrictions is the most common invalid operation in this type of issue: restart after changing, upload again, and it is still 413.

Why does the browser only show a connection error

The phrase 'The browser cannot correctly display this error' in the document refers to the actual phenomenon: when the user uploads halfway, the page only gives a vague failure prompt, and it is not clear that it is a volume problem.

This has two impacts on troubleshooting. First, user feedback usually won't say 'return 413', but 'it can't be uploaded', so you need to check the server status code yourself; second, the response received by the front-end script may be incomplete, and relying on interface prompts for location is unreliable.

By the way, here's a common misjudgment: this kind of failure looks like a timeout or a network disconnection. The difference lies in the size - if a smaller file can be uploaded successfully, it's a limit issue rather than a link issue.

The comparison and modification order of the three-tier restrictions

The upload and import restrictions within the site are usually distributed in three layers, each managing different things:

Level What does it manage? Typical over-limit performance Modification order
Entry and gateway layer The limit of the entire request body Return 413, no program log record Change this layer first
Program execution layer Limit of individual file and form field Request comes into the application and returns business error prompt Check this layer again
Business function layer Self-limit of certain actions, such as import package size Task fails and gives a reason Adjust according to functional requirements

The reason why the order cannot be reversed is very simple: the upper layer has not passed, and the lower layers have not been executed. In the three layers, as long as one layer is smaller than the target value, the actual available upper limit is that smaller value.

When making changes, configure according to the 'target volume reserve': the value of the entry layer should be greater than the program layer, and the value of the program layer should be greater than the value needed for a single operation in the business layer. The reversed configuration will bring a phenomenon that is very difficult to describe - small files are normal, and large files report application layer errors, looking like a program bug.

The actual practice when importing large files in batches

AnQiCMS supports batch document import, which can be done through ZIP compressed packages and Excel spreadsheets in two ways. When importing large compressed packages, the layers above are the ones that need to pass through.

There are four methods available, arranged from low to high cost:

Firstly, unpack. Cut into multiple smaller packages by category or time and import them in stages. No configuration is required, and it will not raise the upper limit of the entry layer.

Secondly, compress the content first and then package. Attachments and images occupy most of the package body. Before importing, upload the resources that do not need to be retained in the package separately through media upload, and the package body will be much smaller.

The third is to relax the upper limit of the entry layer. Confirm the need to support large package import for a long time before changing, and after changing, check the value of the program layer at the same time, adjusting both layers together has meaning.

The fourth is to submit in batches through the interface. AnQiCMS provides the /api/import/archive document content import interface, and also supports querying whether it exists by title, submitting in batches by item or in small batches in batch scenarios, the lowest affected by the limit may be the lowest.

The deployment form will affect which configuration: AnQiCMS's deployment methods include Baota panel one-click deployment, LNMP command line deployment, and Docker image, the service listens to port 8001 by default, and there is usually a reverse proxy in front of the site. For panel deployment, the site entry is limited to the panel's site configuration; for image plus self-built proxy, it is limited to the configuration in the front-end gateway; only when the service port is exposed directly, it is mainly limited by the program itself.

After the modification, do a real test: take a file slightly smaller than the target value to go through the entire process, not just look at the configuration.

Common questions

Is setting the limit to zero equivalent to removing the restriction?Setting zero in the document means that no request body check is performed, but this does not mean that the subsequent layers also do not check: constraints at the program and business layers still exist. Moreover, not checking the size of the request body will leave the memory and disk pressure to the application to bear, and it is not recommended to configure it this way for public network entry.

Why is it still failing after changing the configuration?There are three possibilities: the object changed is not the current effective one (common in multi-site or container scenarios), there is still one layer of the CDN in front or the edge node, and the program restart did not take effect. Try using a file that is just over the limit layer by layer, and you can locate which layer has not been changed properly.

Is there a relationship between upload limits and security?Yes. The limit at the entry layer is also the first control for slow large packets and resource usage. When releasing, give the value according to actual needs, do not raise it too high at once.

When there are many images, can the limit only be increased?Not necessarily. Media upload or batch processing through the interface can avoid large packets, and increasing the limit should be a last resort rather than the first action.

Related articles

After replacing the certificate, the page style is missing half, how to clear the http external links in the https page?

After replacing the certificate, the style is missing half, usually due to the residual http resources in the https page being blocked by the browser. The cleaning order is to first locate the residual references, then batch replace them with internal relative addresses or encrypted addresses according to the main text data, template, and configuration, and finally close the jump rules together.

2026-10-10

Which parts need to be changed when replacing HTTP with HTTPS, including the internal addresses and redirections?

Changing from HTTP to HTTPS is not just about installing certificates. It also involves: the 301 redirect rules for old addresses, hardcoded absolute addresses within the site, the protocol in the sitemap and robots, pseudo-static and standard address configuration, as well as hard-coded links in navigation and single-page applications. The recommended sequence is to first handle certificates and redirects, then perform bulk replacements, and finally update the checklist files and review mixed content.

2026-10-10

Certificates are valid for ninety days and automatically renewed, where should this be configured?

The default validity period of the HTTPS certificate is ninety days, and renewal should not wait until the browser alarms. Automatic renewal should be as a fixed scheduled task in the deployment process, after the certificate is issued and before the service is reloaded, and it is recommended to trigger once every sixty days. To confirm that it has been renewed, you need to check the actual expiration date of the online certificate, and also check the old address redirection and mixed content, and keep a backup before changing the certificate.

2026-10-10

Should compression be done in the program or in the Web server, and should static files be pre-compressed?

Dynamic compression consumes CPU each time a request is made and is limited by minimum length and type list; pre-compression shifts the cost to the publishing stage, sending the existing .gz file directly, but ensuring that the modification time of the original file matches that of the compressed file. The two layers are not substitutes: the content management program is responsible for generation, and the web server is responsible for choosing the sending method based on the client and type, with the help of caching and reverse proxy layers to achieve stable loading speed benefits.

2026-10-09

The recommended operating environment version on the official website is two levels lower than the minimum version that can run, which level should be configured?

In the same requirement page, there are often two levels of running environment numbers: one level suggests the version supported by the host, and one level is the compatible lower limit that can also run. Often followed by a sentence that these versions have entered the official discontinuation of maintenance, which may expose the site to security risks. This article explains what the two levels of numbers mean, why new sites are configured according to the recommended level, and provides a three-step order to check the language runtime, database, and transmission encryption, as well as which restrictions will disappear after switching to the compiled technology stack.

2026-10-10

Where is the backend entry of the online experience station, and which capabilities should be verified during the trial?

The information and backend entry path of the experience station are written in the documentation, and the demonstration account is in the README demonstration area. This article provides a 30-minute trial list: content model and columns, AI dialogue and toolset, skill and intent directory, access and approval, included related modules, and explain which conclusions should not be obtained from the experience station.

2026-10-11

How to match the program port and gateway port when running the website building program in the container

Containerized deployment of website programs requires three layers of ports: program listening, container mapping, and gateway outward. This article takes the default listening port as an example to explain the corresponding relationship of the three layers, typical performance when the mapping is written incorrectly, and the request headers that need to be supplemented for reverse proxy and the items that need to be checked after deployment.

2026-10-11

Why are all the client addresses logged in the log all proxy addresses when a proxy is hung in front of the website?

After the reverse proxy, only the proxy address remains in the log because the connection indeed comes from the proxy. The real source needs to be obtained from the forwarding header, but this header can be forged, and only the section appended by the trusted proxy should be believed when retrieving the value. This article explains the alignment of the order, trust boundaries, and the three steps on the deployment side.

2026-10-11