Life Saving Nextcloud Knowledge: Limiting Request Body Size in Apache Using .htaccess
In web development, the .htaccess file is a powerful configuration tool for Apache-based environments. When running a self-hosted Nextcloud instance, proper .htaccess tuning is essential not only for performance, but also for security.
One important directive you may want to enforce is LimitRequestBody, which controls how much data a client can send in an HTTP request—critical for handling uploads safely and preventing potential abuse.
This article walks you through exactly how to use this directive with Nextcloud, along with related considerations for upload limits in Apache, PHP, WebDAV, and different hosting environments.
Table of Contents
- What Is LimitRequestBody?
- Why Limit Request Size in Nextcloud?
- How to Configure LimitRequestBody in .htaccess
- Increasing Upload Limits in PHP for Nextcloud
- Nextcloud Maximum File Size Limits (Apache, Nginx, WebDAV, Clients)
- Drawbacks of Setting the Limit Too Low
- Conclusion
1. What Is LimitRequestBody?
LimitRequestBody is an Apache directive that sets the maximum allowed size (in bytes) for HTTP request bodies—typically affecting file uploads via POST/PUT.
By default, Apache has no limit, meaning uploads can be massive if not restricted. For a system like Nextcloud that frequently handles large files, setting a sane limit is important.
2. Why Limit Request Size in Nextcloud?
Using LimitRequestBody helps:
- Prevent excessive load during massive uploads
- Mitigate certain denial-of-service (DoS) risks
- Enforce consistent upload limits server-wide
- Add protection where PHP or application limits fail
This is especially important when hosting Nextcloud on a VPS where you control your own Apache configuration.
3. How to Configure LimitRequestBody in .htaccess
Nextcloud uses an .htaccess file in its root directory. To set a maximum request body size, add:
LimitRequestBody 104857600
This sets the upload limit to 100 MB (104857600 bytes).
Notes:
- Adjust the value for your needs (e.g., 1G = 1073741824).
- Some shared hosting providers override
.htaccesslimits. - If the directive doesn’t apply, your Apache config may restrict overrides.
4. Increasing Upload Limits in PHP for Nextcloud
Apache is only half the equation—PHP also enforces upload size limits:
upload_max_filesizepost_max_size
Option 1 — Edit php.ini
For 100 MB uploads:
upload_max_filesize = 100M
post_max_size = 100M
Option 2 — Use .htaccess (PHP module mode)
php_value upload_max_filesize 100M
php_value post_max_size 100M
PHP-FPM users must edit the FPM pool config instead.
And then:
systemctl restart apache2
5.Nextcloud Maximum File Size Limits Across Environments
Nextcloud WebDAV
Upload limits depend on the web server:
Apache → LimitRequestBody
Nginx → client_max_body_size
Example Nginx config:
client_max_body_size 100m;
Nextcloud Desktop / Mobile Clients
These follow:
- PHP limits
- Server body size limits
- Filesystem limits
Nextcloud itself does not impose a hard limit.
Unraid + Nextcloud
Unraid does not limit file size. You control the limits through your Apache/PHP configuration.
6. Drawbacks of Setting the Limit Too Low
While useful for safety, setting the limit too small may cause:
- Upload failures
- Increased retries and load
- Sync errors
- Unnecessary user frustration
Always test uploads after applying a new limit.
7. Conclusion
LimitRequestBody is one of those life-saving Nextcloud tips that keeps your server stable, secure, and predictable. Paired with proper PHP configuration, this ensures your self-hosted cloud stays fast and reliable—whether you’re syncing family photos or running an office-wide cloud storage system.
It’s one small part of a proper security posture, but an essential one. Combined with firewalls, rate limiting, monitoring, and regular updates, it forms a strong foundation for a resilient Nextcloud environment.