413 Status code with "correct" config

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.0
  • Operating system and version (e.g., Ubuntu 24.04):
    • NixOS 24.11
  • Web server and version (e.g, Apache 2.4.25):
    • docker image version 31.0.0
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • Traefik
  • PHP version (e.g, 8.3):
    • docker image version 31.0.0
  • Is this the first time you’ve seen this error? (Yes / No):
    • No
  • When did this problem seem to first start?
    • ~6 months ago
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Docker image
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

Hey! For the past month, I’ve tried to allow bigger uploads on the default nextcloud docker image with Apache (latest 31.0.0) without success. I always get the 413 Entity too large error from the linux client. I’ve set every possible bit of configuration found here and there to allow it.

Steps to replicate it (hint: details matter!):

Using this config for docker-compose service:

image: datahearth/nextcloud-docker:31
restart: unless-stopped
user: ${UID}:${GID}
dns:
  - 1.1.1.1
  - 1.0.0.1
networks:
  - reverse-proxy
  - database
volumes:
  - ${APPDATA}/nextcloud/app:/var/www/html
  - ${APPDATA}/nextcloud/app-hooks/before-starting:/docker-entrypoint-hooks.d/before-starting
  - ${SHARES}/nextcloud:/data
  - ${SHARES}/logs/nextcloud:/var/log/nextcloud
environment:
  TZ: ${TZ}
  POSTGRES_HOST: postgresql16:5432
  POSTGRES_USER: ${NEXTCLOUD_DB_USER}
  POSTGRES_PASSWORD: ${NEXTCLOUD_DB_PASSWD}
  POSTGRES_DB: ${NEXTCLOUD_DB_NAME}
  SMTP_HOST: xxx
  SMTP_SECURE: xxx
  SMTP_PORT: xxx
  SMTP_NAME: ${SENDGRID_USER}
  SMTP_PASSWORD: ${SENDGRID_PASSWD}
  MAIL_FROM_ADDRESS: xxx
  MAIL_DOMAIN: xxx
  NEXTCLOUD_DATA_DIR: /data
  NEXTCLOUD_TRUSTED_DOMAINS: nextcloud.antoine-langlois.net traefik localhost
  NEXTCLOUD_INIT_HTACCESS: true
  PHP_MEMORY_LIMIT: 1024M
  PHP_UPLOAD_LIMIT: 16G
  APACHE_BODY_LIMIT: 0
labels:
  traefik.enable: true
  traefik.http.routers.nextcloud-unsecured.rule: Host(`nextcloud.${EXTERNAL_DN}`)
  traefik.http.routers.nextcloud-unsecured.entrypoints: web
  traefik.http.routers.nextcloud-unsecured.middlewares: crowdsec-bouncer@file, https-redirect@file
  traefik.http.routers.nextcloud.rule: Host(`nextcloud.${EXTERNAL_DN}`)
  traefik.http.routers.nextcloud.entrypoints: websecure
  traefik.http.routers.nextcloud.tls.certresolver: default
  traefik.http.routers.nextcloud.middlewares: nxt-headers@file, nxt-redirect@file, crowdsec-bouncer@file

Log entries

Nextcloud

Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log located in your data directory). Feel free to use a pastebin/gist service if necessary.

172.71.123.35 - antoine [01/Mar/2025:20:11:22 +0100] "MKCOL /remote.php/dav/uploads/antoine/4154137805 HTTP/1.1" 201 496 "-" "Mozilla/5.0 (Windows) mirall/3.15.3 (build 20250107) (Nextcloud, windows-10.0.22631 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
172.71.123.35 - antoine [01/Mar/2025:20:11:25 +0100] "PUT /remote.php/dav/uploads/antoine/4154137805/00001 HTTP/1.1" 201 496 "-" "Mozilla/5.0 (Windows) mirall/3.15.3 (build 20250107) (Nextcloud, windows-10.0.22631 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
172.71.123.35 - antoine [01/Mar/2025:20:11:49 +0100] "DELETE /remote.php/dav/uploads/antoine/4154137805 HTTP/1.1" 204 440 "-" "Mozilla/5.0 (Windows) mirall/3.15.3 (build 20250107) (Nextcloud, windows-10.0.22631 ClientArchitecture: x86_64 OsArchitecture: x86_64)"

Web Browser

None

Web server / Reverse Proxy

172.71.123.35 - - [01/Mar/2025:19:11:22 +0000] "MKCOL /remote.php/dav/uploads/antoine/4154137805 HTTP/2.0" 201 0 "-" "-" 15758 "nextcloud@docker" "http://172.21.0.12:80" 1075ms
172.71.134.115 - - [01/Mar/2025:19:11:25 +0000] "PROPFIND /remote.php/dav/files/antoine/ HTTP/2.0" 207 248 "-" "-" 15760 "nextcloud@docker" "http://172.21.0.12:80" 371ms
172.71.123.35 - - [01/Mar/2025:19:11:24 +0000] "PUT /remote.php/dav/uploads/antoine/4154137805/00001 HTTP/2.0" 201 0 "-" "-" 15759 "nextcloud@docker" "http://172.21.0.12:80" 3029ms
172.71.123.35 - - [01/Mar/2025:19:11:48 +0000] "PROPFIND /remote.php/dav/files/antoine/ HTTP/2.0" 207 2041 "-" "-" 15763 "nextcloud@docker" "http://172.21.0.12:80" 43ms
172.71.123.35 - - [01/Mar/2025:19:11:49 +0000] "DELETE /remote.php/dav/uploads/antoine/4154137805 HTTP/2.0" 204 0 "-" "-" 15766 "nextcloud@docker" "http://172.21.0.12:80" 136ms

Configuration

Nextcloud

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "maintenance_window_start": 1,
        "secret": "***REMOVED SENSITIVE VALUE***",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "trusted_domains": [
            "nextcloud.antoine-langlois.net",
            "traefik",
            "localhost"
        ],
        "forwarded_for_headers": [
            "X-Forwarded-For",
            "HTTP_X_FORWARDED_FOR"
        ],
        "version": "31.0.0.18",
        "overwrite.cli.url": "https:\/\/nextcloud.antoine-langlois.net",
        "overwritehost": "nextcloud.antoine-langlois.net",
        "overwriteprotocol": "https",
        "installed": true,
        "maintenance": false,
        "twofactor_enforced": "true",
        "twofactor_enforced_groups": [
            "admin"
        ],
        "twofactor_enforced_excluded_groups": [],
        "default_phone_region": "FR",
        "theme": "",
        "filelocking.enabled": true,
        "upgrade.disable-web": true,
        "dbtype": "pgsql",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "log_type": "file",
        "logfile": "\/var\/log\/nextcloud\/nextcloud.log",
        "loglevel": 1,
        "mail_smtpauth": true,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpsecure": "tls",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "enable_previews": true,
        "preview_concurrency_all": 16,
        "preview_max_filesize_image": -1,
        "preview_max_memory": -1,
        "enabledPreviewProviders": [
            "OC\\Preview\\PNG",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\GIF",
            "OC\\Preview\\BMP",
            "OC\\Preview\\XBitmap",
            "OC\\Preview\\MP3",
            "OC\\Preview\\Krita",
            "OC\\Preview\\HEIC",
            "OC\\Preview\\MOV",
            "OC\\Preview\\JPG",
            "OC\\Preview\\ICO",
            "OC\\Preview\\MP4",
            "OC\\Preview\\DNG",
            "OC\\Preview\\RAW",
            "OC\\Preview\\MKV",
            "OC\\Preview\\Movie"
        ],
        "app_install_overwrite": [
            "unsplash",
            "memories",
            "maps",
            "facerecognition"
        ],
        "htaccess.RewriteBase": "\/",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "mail_smtpmode": "smtp",
        "mail_smtpauthtype": "LOGIN",
        "memories.db.triggers.fcu": true,
        "memories.exiftool": "\/var\/www\/html\/custom_apps\/memories\/bin-ext\/exiftool-amd64-glibc",
        "memories.vod.path": "\/var\/www\/html\/custom_apps\/memories\/bin-ext\/go-vod-amd64",
        "memories.vod.disable": false,
        "memories.vod.ffmpeg": "\/usr\/bin\/ffmpeg",
        "memories.vod.ffprobe": "\/usr\/bin\/ffprobe",
        "dbtableprefix": "oc_",
        "memories.gis_type": 2,
        "preview_ffmpeg_path": "\/usr\/bin\/ffmpeg"
    }
}

Apps

Enabled:
  - activity: 4.0.0
  - admin_audit: 1.21.0
  - app_api: 5.0.2
  - bruteforcesettings: 4.0.0
  - calendar: 5.1.2
  - cloud_federation_api: 1.14.0
  - contacts: 7.0.1
  - contactsinteraction: 1.12.0
  - dashboard: 7.11.0
  - dav: 1.33.0
  - facerecognition: 0.9.60
  - federatedfilesharing: 1.21.0
  - files: 2.3.1
  - files_downloadlimit: 4.0.0
  - files_pdfviewer: 4.0.0
  - files_reminders: 1.4.0
  - files_sharing: 1.23.1
  - files_trashbin: 1.21.0
  - files_versions: 1.24.0
  - firstrunwizard: 4.0.0
  - logreader: 4.0.0
  - lookup_server_connector: 1.19.0
  - maps: 1.5.0
  - memories: 7.5.2
  - notes: 4.11.0
  - notifications: 4.0.0
  - oauth2: 1.19.1
  - password_policy: 3.0.0
  - photos: 4.0.0-dev.1
  - previewgenerator: 5.8.0
  - privacy: 3.0.0
  - profile: 1.0.0
  - provisioning_api: 1.21.0
  - recognize: 9.0.0
  - recommendations: 4.0.0
  - related_resources: 2.0.0
  - serverinfo: 3.0.0
  - settings: 1.14.0
  - sharebymail: 1.21.0
  - suspicious_login: 9.0.1
  - systemtags: 1.21.1
  - theming: 2.6.1
  - twofactor_backupcodes: 1.20.0
  - twofactor_totp: 13.0.0-dev.0
  - updatenotification: 1.21.0
  - viewer: 4.0.0
  - webhook_listeners: 1.2.0
  - workflowengine: 2.13.0
Disabled:
  - circles: 31.0.0-dev.0 (installed 27.0.1)
  - comments: 1.21.0 (installed 1.17.0)
  - encryption: 2.19.0
  - federation: 1.21.0 (installed 1.17.0)
  - files_external: 1.23.0
  - nextcloud_announcements: 3.0.0 (installed 1.18.0)
  - support: 3.0.0 (installed 1.10.0)
  - survey_client: 3.0.0 (installed 1.15.0)
  - text: 5.0.0 (installed 3.8.0)
  - twofactor_nextcloud_notification: 5.0.0
  - user_ldap: 1.22.0
  - user_status: 1.11.0 (installed 1.7.0)
  - weather_status: 1.11.0 (installed 1.7.0)

Two things come to mind:

  • the above is correct, but if it was added after you started the container… A container restart won’t add the setting. Environment variables require recreating the container.
  • I see you’re using crowdsec. So perhaps something there?

Hey!
Thanks for your response. I didn’t thought about crowdsec. But it wasn’t the problem. I totally disabled the crowdsec plugin and the crowdsec container (just in case), it didn’t solved the problem.

I always recreate the container when applying new configurations via docker compose.

I also tried modifying the PHP_MEMORY_LIMIT. It seems to have an effect somewhere on Windows client.
A file ~1.4GB is almost uploading entirely, but loops back at the end, re-upload, then failed because the HTTP connection “was closed”. Strange enough, the Connection closed doesn’t match the log when clicking on the item, stating ... Not Found.

After every tweak I’ve done, I’ve started to believe this could be a bug.

A 413 comes from either the web server or reverse proxy (or something like Cloudflare) almost always. It should be getting logged somewhere server-side (or at CF if involved).

You said you’re not using CF. Are you certain there isn’t something else in your end-to-end path?

EDIT: Looks like your public hostname resolves to Cloudflare IP addresses… so that’s the reason. CF’s free plan limits HTTP body sizes to 100 MB. You either need to eliminate CF or set your client chunk sizes to <= 100 MiB (the web UI is already set to 100 MiB so it likely works).

Hey! Thank you for pointing out. I though the CF question was about services like cloudflare tunnels, etc. I didn’t though the CDN would apply such limitation…

It was indeed the problem.

For future reference, here’s Cloudflare CDN documentation regarding the body size limit. If you use the proxy feature in the DNS record, you’ll need to either deactivate it or simply upgrade your plan.

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.