Self-Hosted Cloud Blueprint

Deploying Production-Grade Nextcloud Hub on Netcup VPS

Complete blueprint for running an enterprise-grade Nextcloud Hub on Netcup infrastructure: Docker Compose, PostgreSQL 16, Redis locking, automated cron daemon, storage volume partitioning, and Nginx SSL proxying.

M
Markus S. (Senior Cloud Infrastructure Engineer)
Verified & Tested: September 2026
⏱️ 12 min read

1. Docker Compose Stack Architecture

For production-grade scalability, we deploy a four-tier container architecture: PostgreSQL 16 as the robust relational database, Redis 7 for high-speed in-memory transactional file locking, the official Nextcloud image for application serving, and an isolated Cron container for background tasks.

/opt/nextcloud/docker-compose.yml

# Production Nextcloud Stack for Netcup VPS

services:

  db:

    image: postgres:16-alpine

    restart: unless-stopped

    volumes:

      - ./db_data:/var/lib/postgresql/data

    environment:

      - POSTGRES_DB=nextcloud

      - POSTGRES_USER=nextcloud

      - POSTGRES_PASSWORD=CHANGE_ME_TO_STRONG_PASSWORD_2026

  redis:

    image: redis:7-alpine

    restart: unless-stopped

    command: redis-server --requirepass REDIS_SECRET_TOKEN_2026

  app:

    image: nextcloud:30-apache

    restart: unless-stopped

    ports:

      - "127.0.0.1:8080:80"

    depends_on:

      - db

      - redis

    volumes:

      - ./html:/var/www/html

      - /mnt/storage/data:/var/www/html/data

    environment:

      - POSTGRES_HOST=db

      - POSTGRES_DB=nextcloud

      - POSTGRES_USER=nextcloud

      - POSTGRES_PASSWORD=CHANGE_ME_TO_STRONG_PASSWORD_2026

      - REDIS_HOST=redis

      - REDIS_HOST_PASSWORD=REDIS_SECRET_TOKEN_2026

      - PHP_MEMORY_LIMIT=2048M

      - PHP_UPLOAD_LIMIT=16G

  cron:

    image: nextcloud:30-apache

    restart: unless-stopped

    volumes:

      - ./html:/var/www/html

      - /mnt/storage/data:/var/www/html/data

    entrypoint: /cron.sh

    depends_on:

      - db

      - redis

2. PHP Memory & Big File Upload Tuning

Default PHP allocations restrict uploads to modest sizes and cap RAM at 512MB. When synchronizing large backup archives or high-resolution media, this triggers HTTP timeouts. Injecting these parameters directly eliminates the need to maintain manual php.ini overrides:

🚀 Recommended Parameter Values:

  • PHP_MEMORY_LIMIT=2048M (Netcup VPS 1000/2000 G12 include 8-16GB RAM; 2GB allocation is optimal)
  • PHP_UPLOAD_LIMIT=16G (Allows single-file direct uploads up to 16GB with client-side chunking)
  • APCu / OPcache bytecode cache is pre-enabled by default in official Nextcloud Docker images

3. Dedicated Background Cron Service

By default, Nextcloud triggers background maintenance via AJAX during browser page visits. On active instances with thousands of assets or thumbnail generation queues, AJAX fails reliably due to 60-second HTTP execution timeouts.

⭐ Best Practice: Isolated Cron Container

As demonstrated in our compose stack, we run a dedicated container instance whose entrypoint is /cron.sh. It invokes CLI occ maintenance tasks every 5 minutes in pure background fashion. Afterwards, navigate to Nextcloud Settings → Administration → Basic Settings and set Background jobs to "Cron (recommended)".

4. Netcup Storage Mounts & Permissions

If you attached a Netcup Block Storage volume to your VPS or Root Server, mount the volume under /mnt/storage and isolate Nextcloud user payload files from the OS root partition:

Formatting & mounting storage volume

# 1. Identify attached block device (usually /dev/vdb or /dev/sdb)

lsblk

# 2. Format with ext4 journaling filesystem

mkfs.ext4 -m 1 /dev/vdb

# 3. Create mountpoint and persist in /etc/fstab

mkdir -p /mnt/storage/data

echo "$(blkid -s UUID -o value /dev/vdb) /mnt/storage ext4 defaults,noatime 0 2" >> /etc/fstab

mount -a

# 4. Set permissions: internal container www-data uses UID/GID 33

chown -R 33:33 /mnt/storage/data

chmod 750 /mnt/storage/data

5. Nginx Reverse Proxy & A+ Security Headers

To ensure seamless CalDAV/CardDAV synchronization across iOS/Android and achieve an A+ security audit score in the Nextcloud admin console, your outer Nginx reverse proxy must pass WebDAV rewrite rules and HSTS headers:

/etc/nginx/sites-available/nextcloud.conf

server {

  listen 443 ssl http2;

  server_name cloud.yourdomain.com;

  # Let’s Encrypt certificate paths

  ssl_certificate /etc/letsencrypt/live/cloud.yourdomain.com/fullchain.pem;

  ssl_certificate_key /etc/letsencrypt/live/cloud.yourdomain.com/privkey.pem;

  # Security headers for Nextcloud A+ rating

  add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

  client_max_body_size 16G;

  # CalDAV/CardDAV auto-discovery redirects

  location ^~ /.well-known/carddav { return 301 https://$host/remote.php/dav/; }

  location ^~ /.well-known/caldav { return 301 https://$host/remote.php/dav/; }

  location / {

    proxy_pass http://127.0.0.1:8080;

    proxy_set_header Host $host;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_set_header X-Forwarded-Proto https;

    proxy_request_buffering off;

  }

}

6. Troubleshooting & FAQs

Q:Why do large file uploads fail with "413 Request Entity Too Large"?

This occurs when your outer reverse proxy rejects large payloads. Add "client_max_body_size 16G;" to your Nginx server or location block, and verify that PHP_UPLOAD_LIMIT=16G is defined in the container.

Q:Why is Redis mandatory for transactional file locking in Nextcloud?

Without Redis, Nextcloud delegates file locking to MariaDB/PostgreSQL, quickly exhausting DB connection pools and causing deadlocks. Redis keeps locks in RAM, accelerating multi-device synchronization by 300%+.

Q:How to resolve the Nextcloud administrative warning about incorrect reverse proxy headers?

Specify the proxy IP address inside trusted_proxies in config/config.php, set overwriteprotocol => https, and verify that Nginx forwards X-Forwarded-Proto and X-Forwarded-For headers.

MS
Article Author & Infrastructure Lead10+ Years European Datacenter & Virtualization Practice

Markus S.

Senior Cloud Infrastructure Architect & Linux Sysadmin

Markus focuses on European cloud hosting economics, server performance optimization, and KVM virtualization. All benchmarks, setup guides, and VAT exemption procedures are verified on self-funded Netcup instances hosted in the Nuremberg datacenter (AMD EPYC hardware).

🛡️100% Independent & Self-Funded (No sponsored influence)
Real Hardware Benchmarks (AMD EPYC 9645 / Genoa clusters)
🔄Daily Automated Verification (All promo codes regularly validated)
Editorial Independence & Integrity Policy: Netcup.Discount maintains complete editorial neutrality. While some links may earn referral credit, our benchmarks, configuration advice, and hosting evaluations remain strictly objective.
⚡ Real-time Synced Pool

💰 Netcup Verified Coupons & Discounts

We maintain an updated collection of verified netcup discount codes, with real-time automatic synchronization. Get up to 30% off or free months on your next order.

Browse All Coupons →