Auto-alojar Nextcloud: Guía completa de configuración 2026
Tutoriales 14 de febrero de 2026 10 min read

Auto-alojar Nextcloud: Guía completa de configuración 2026

H

Hostly Team

Self-Hosting Enthusiast

Despliega tu propio almacenamiento en la nube privado con Nextcloud y Docker. Reemplaza Google Drive, Dropbox e iCloud con una solución auto-alojada que mantiene tus archivos bajo tu control.

Every day, billions of files flow through Google Drive, Dropbox, and iCloud. Convenience is undeniable — but so is the trade-off: your documents, photos, and sensitive data live on someone else's servers, governed by their terms, accessible to their algorithms, and vulnerable to their security decisions.

There's a better way. Nextcloud is a powerful, open-source platform that replicates everything you love about commercial cloud storage — file sync, mobile apps, calendar, contacts, collaborative documents — while keeping your data entirely on your own hardware. No monthly fees. No storage limits except your own disks. No privacy compromises.

In this comprehensive guide, we'll deploy Nextcloud using Docker Compose, configure it for optimal performance, and set up all the essential features. By the end, you'll have a fully functional private cloud that rivals any commercial offering.

Why Self-Host Nextcloud?

Before we dive into the setup, let's understand what makes Nextcloud the go-to choice for self-hosted cloud storage:

FeatureNextcloudGoogle DriveDropbox
CostFree (self-hosted)$2-20/month$12-24/month
StorageUnlimited (your disks)15GB-5TB2GB-3TB
Data LocationYour serverGoogle's cloudDropbox's cloud
End-to-End Encryption✅ Available⚠️ Paid add-on
File Sync✅ All platforms
Mobile Apps✅ iOS & Android
Calendar/Contacts✅ Built-inSeparate service
Collaborative Docs✅ OnlyOffice/Collabora✅ Paper
Video Calls✅ Nextcloud TalkGoogle Meet
Privacy✅ Complete control❌ Data mining⚠️ Limited

The key advantage: Nextcloud is modular. Start with file storage, then add calendar sync, video conferencing, collaborative editing, and dozens of other apps — all integrated into a single platform.

What You'll Need

The requirements scale with your usage, but here's a solid starting point:

  • A server — VPS with 2GB+ RAM, home server, or NAS. Nextcloud works on anything from a Raspberry Pi 4 to enterprise hardware.
  • Storage — At least 50GB for a personal setup. For families or media storage, consider 1TB+.
  • Docker and Docker Compose — the cleanest installation method.
  • A domain name (recommended) — for HTTPS access and mobile app connectivity.
  • 30-45 minutes — for a complete setup with all optimizations.

💡 Hardware Recommendations

  • 👤Personal use (1-2 users): 2GB RAM, 2 CPU cores, 100GB storage
  • 👨‍👩‍👧‍👦Family (3-10 users): 4GB RAM, 4 CPU cores, 500GB-2TB storage
  • 🏢Small team (10-50 users): 8GB+ RAM, 8 CPU cores, 2TB+ storage with RAID

Step 1: Install Docker

If Docker isn't installed yet, set it up with the official convenience script:

# Install Docker
curl -fsSL https://get.docker.com | sh

# Add your user to the docker group
sudo usermod -aG docker $USER

# Log out and back in, then verify
docker --version
docker compose version

Step 2: Create the Project Directory

Create a dedicated directory for your Nextcloud installation:

# Create and enter the directory
mkdir ~/nextcloud
cd ~/nextcloud

# Create subdirectories for data
mkdir -p data config

Step 3: Create the Docker Compose File

Create a docker-compose.yml file with the optimized configuration:

nano docker-compose.yml

Paste this production-ready configuration:

services:
  db:
    image: mariadb:10.11
    container_name: nextcloud-db
    restart: unless-stopped
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQL_PASSWORD: ${DB_PASSWORD}
    volumes:
      - ./db:/var/lib/mysql
    networks:
      - nextcloud

  redis:
    image: redis:alpine
    container_name: nextcloud-redis
    restart: unless-stopped
    networks:
      - nextcloud

  nextcloud:
    image: nextcloud:stable
    container_name: nextcloud-app
    restart: unless-stopped
    depends_on:
      - db
      - redis
    environment:
      MYSQL_HOST: db
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQL_PASSWORD: ${DB_PASSWORD}
      REDIS_HOST: redis
      NEXTCLOUD_ADMIN_USER: ${ADMIN_USER}
      NEXTCLOUD_ADMIN_PASSWORD: ${ADMIN_PASSWORD}
      NEXTCLOUD_TRUSTED_DOMAINS: ${DOMAIN}
      OVERWRITEPROTOCOL: https
      OVERWRITECLIURL: https://${DOMAIN}
      PHP_MEMORY_LIMIT: 1G
      PHP_UPLOAD_LIMIT: 10G
    volumes:
      - ./data:/var/www/html/data
      - ./config:/var/www/html/config
      - ./apps:/var/www/html/custom_apps
    networks:
      - nextcloud

  caddy:
    image: caddy:latest
    container_name: nextcloud-caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - ./caddy-data:/data
      - ./caddy-config:/config
    networks:
      - nextcloud

networks:
  nextcloud:
    driver: bridge

Let's break down this configuration:

  • MariaDB — Enterprise-grade database with transaction settings optimized for Nextcloud.
  • Redis — In-memory cache for dramatically faster performance.
  • Nextcloud — The main application with generous PHP limits for large file uploads.
  • Caddy — Reverse proxy with automatic HTTPS certificate management.

Step 4: Create Environment Variables

Create a .env file to store your configuration securely:

nano .env

Add your settings:

# Database passwords (generate with: openssl rand -base64 32)
DB_ROOT_PASSWORD=your-secure-root-password-here
DB_PASSWORD=your-secure-db-password-here

# Admin credentials
ADMIN_USER=admin
ADMIN_PASSWORD=your-secure-admin-password-here

# Your domain
DOMAIN=cloud.yourdomain.com

🔑 Generate Secure Passwords

# Generate secure random passwords
openssl rand -base64 32

# Use different passwords for each variable!

Never use simple passwords for database credentials — they protect all your files.

Step 5: Create the Caddyfile

Create the Caddy configuration for automatic HTTPS:

nano Caddyfile

Add this configuration (replace with your domain):

cloud.yourdomain.com {
    reverse_proxy nextcloud-app:80

    header {
        Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
        X-Content-Type-Options "nosniff"
        X-Frame-Options "SAMEORIGIN"
        Referrer-Policy "strict-origin-when-cross-origin"
    }

    redir /.well-known/carddav /remote.php/dav 301
    redir /.well-known/caldav /remote.php/dav 301

    request_body {
        max_size 10GB
    }
}

This configuration includes:

  • Automatic Let's Encrypt SSL certificates
  • Security headers for browser protection
  • CalDAV/CardDAV redirects for calendar and contacts
  • 10GB upload limit to match our PHP configuration

Step 6: Launch Nextcloud

Start all containers:

# Pull images and start
docker compose up -d

# Watch the logs
docker compose logs -f

The first startup takes 2-5 minutes as Nextcloud initializes the database and generates encryption keys. Wait until you see:

nextcloud-app  | Initializing finished

Step 7: Complete the Setup

Navigate to https://cloud.yourdomain.com in your browser. You'll see the Nextcloud login screen. Log in with the admin credentials from your .env file.

On first login, you'll be prompted to install recommended apps. I suggest:

  • Calendar — Full CalDAV calendar with sharing
  • Contacts — CardDAV contacts that sync everywhere
  • Notes — Markdown note-taking with sync
  • Tasks — Todo lists integrated with calendar
  • Photos — AI-powered photo gallery and viewer

Step 8: Install Desktop and Mobile Clients

The true power of Nextcloud emerges when you install sync clients on all your devices.

Desktop Sync Client

Download from nextcloud.com/install. Available for:

  • Windows — Integrates with File Explorer
  • macOS — Integrates with Finder
  • Linux — AppImage, Flatpak, or distro packages

Setup:

  1. Install and launch the client
  2. Enter your server URL: https://cloud.yourdomain.com
  3. Log in with your credentials
  4. Choose folders to sync — start selective to avoid overwhelming your network

Mobile Apps

Install the Nextcloud app from App Store or Google Play.

Key mobile features:

  • Auto-upload photos — Replace Google Photos backup
  • Offline files — Mark files for offline access
  • Share links — Create password-protected sharing links
  • Document scanning — Built-in scanner with auto-crop

Essential Optimizations

Your basic Nextcloud is working, but let's optimize it for peak performance.

Enable Memory Caching

Edit the Nextcloud configuration to enable Redis caching:

# Access the Nextcloud container
docker exec -it nextcloud-app bash

# Edit config.php
nano /var/www/html/config/config.php

Add these lines before the closing );:

  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => [
      'host' => 'redis',
      'port' => 6379,
  ],
  'default_phone_region' => 'US',

Replace US with your country code (FR, DE, GB, etc.).

Set Up Background Jobs

Nextcloud needs regular background tasks for optimal operation. Set up cron:

# On your host machine, add a cron job
crontab -e

# Add this line (runs every 5 minutes)
*/5 * * * * docker exec -u www-data nextcloud-app php cron.php

Then configure Nextcloud to use cron instead of AJAX:

  1. Go to Settings → Administration → Basic settings
  2. Under "Background jobs", select Cron

Configure Email

Email is essential for sharing, notifications, and password resets:

  1. Go to Settings → Administration → Basic settings
  2. Under "Email server", enter your SMTP details
  3. Send a test email to verify

Setting Up Calendar and Contacts Sync

One of Nextcloud's killer features is replacing Google Calendar and Contacts entirely.

CalDAV (Calendar) Setup

Your CalDAV URL is: https://cloud.yourdomain.com/remote.php/dav

iOS/macOS:

  1. Settings → Calendar → Accounts → Add Account → Other
  2. Add CalDAV Account
  3. Server: cloud.yourdomain.com
  4. Username and password from Nextcloud

Android:

  1. Install DAVx5 from Play Store
  2. Add account with your Nextcloud URL
  3. Select calendars to sync

CardDAV (Contacts) Setup

Same process as calendar — the DAVx5 app handles both on Android, and iOS Settings can add CardDAV alongside CalDAV.

Advanced Features

Collaborative Document Editing

Add OnlyOffice or Collabora for real-time document collaboration (like Google Docs):

# Add to your docker-compose.yml
  onlyoffice:
    image: onlyoffice/documentserver:latest
    container_name: nextcloud-onlyoffice
    restart: unless-stopped
    environment:
      JWT_SECRET: your-jwt-secret-here
    networks:
      - nextcloud

Then install the OnlyOffice app from Nextcloud's app store and configure it with your server address.

Nextcloud Talk (Video Calls)

Install the Talk app for secure video conferencing:

  1. Go to Apps → Social & communication → Talk
  2. Install and enable
  3. Create rooms for team meetings or family calls

For better performance with many participants, consider setting up a TURN server.

External Storage

Connect Nextcloud to existing storage:

  • SMB/CIFS — Mount Windows shares or NAS drives
  • FTP/SFTP — Connect to remote servers
  • S3 — Use Amazon S3 or compatible storage (Wasabi, Backblaze B2)
  • WebDAV — Connect to other WebDAV servers

Enable via Apps → Files → External storage support.

Security Hardening

Enable Two-Factor Authentication

Protect your cloud with 2FA:

  1. Install Two-Factor TOTP Provider from apps
  2. Go to Settings → Security → Two-Factor Authentication
  3. Scan QR code with your authenticator app

Enable Server-Side Encryption

For sensitive data, enable encryption:

  1. Go to Settings → Administration → Security
  2. Enable Server-side encryption
  3. Users can also enable end-to-end encryption per-folder

⚠️ Encryption Warning

Server-side encryption cannot be disabled once enabled! Test thoroughly before enabling on production data.

Configure Fail2Ban

Protect against brute-force attacks:

# Create /etc/fail2ban/filter.d/nextcloud.conf
[Definition]
failregex = ^{"reqId":".*","level":2,"time":".*","remoteAddr":"<HOST>".*Login failed
ignoreregex =
# Create /etc/fail2ban/jail.d/nextcloud.local
[nextcloud]
enabled = true
port = 80,443
filter = nextcloud
logpath = /path/to/nextcloud/data/nextcloud.log
maxretry = 5
bantime = 1h

Backup Strategy

Your cloud contains important data — back it up properly:

#!/bin/bash
# backup-nextcloud.sh

BACKUP_DIR="/backup/nextcloud"
DATE=$(date +%Y-%m-%d)

# Enable maintenance mode
docker exec -u www-data nextcloud-app php occ maintenance:mode --on

# Backup database
docker exec nextcloud-db mysqldump -u root -p"$DB_ROOT_PASSWORD" nextcloud > "$BACKUP_DIR/db-$DATE.sql"

# Backup data and config
tar -czf "$BACKUP_DIR/data-$DATE.tar.gz" ~/nextcloud/data ~/nextcloud/config

# Disable maintenance mode
docker exec -u www-data nextcloud-app php occ maintenance:mode --off

# Keep only last 7 backups
find "$BACKUP_DIR" -name "*.sql" -mtime +7 -delete
find "$BACKUP_DIR" -name "*.tar.gz" -mtime +7 -delete

Maintenance and Updates

Updating Nextcloud

Regular updates are crucial for security:

# Pull latest images
cd ~/nextcloud
docker compose pull

# Restart with new version
docker compose up -d

# Run upgrade script
docker exec -u www-data nextcloud-app php occ upgrade

# Clear caches
docker exec -u www-data nextcloud-app php occ maintenance:repair

Monitoring Health

Check Nextcloud's health regularly:

# View system status
docker exec -u www-data nextcloud-app php occ status

# Check for issues
docker exec -u www-data nextcloud-app php occ check

# Scan for missing files
docker exec -u www-data nextcloud-app php occ files:scan --all

Troubleshooting

"Access through untrusted domain"

Add your domain to trusted domains:

docker exec -u www-data nextcloud-app php occ config:system:set trusted_domains 1 --value=cloud.yourdomain.com

Slow Performance

  • Verify Redis is running: docker compose logs redis
  • Check if cron is running: look for "Last job ran" in admin settings
  • Enable APCu in PHP if not already enabled

File Upload Fails

  • Check PHP upload limits in config
  • Verify Caddy allows large uploads (request_body max_size)
  • Check disk space: df -h

Frequently Asked Questions

Can I migrate from Google Drive/Dropbox?

Yes! Download your data from Google Takeout or Dropbox export, then upload to Nextcloud. For Google Contacts and Calendar, export as vCard/iCal and import into Nextcloud.

Is Nextcloud secure enough for sensitive files?

Absolutely. Nextcloud is used by governments and enterprises worldwide. With proper configuration (HTTPS, 2FA, encryption), it exceeds the security of most commercial cloud services.

How much storage do I need?

It depends on your use case. Photos: ~50GB/year per person. Documents: ~10GB. Start with what you have and expand as needed — that's the beauty of self-hosting.

Can multiple family members have their own accounts?

Yes! Create separate user accounts, each with their own private storage plus shared folders for family files.

What's Next?

You now have a powerful private cloud that replaces multiple commercial services. Here's how to make the most of it:

  • Set up auto-upload on mobile devices to replace Google Photos backup
  • Migrate your calendar and contacts from Google
  • Install the Notes app to replace Google Keep or Apple Notes
  • Explore Nextcloud apps — there are hundreds for tasks, music, recipes, and more
  • Combine with other self-hosted services — pair with Vaultwarden for passwords or Immich for photos

Self-hosting your cloud storage isn't just about privacy — it's about independence. Your files, your rules, your infrastructure. No subscription fees creeping up, no storage limits forcing you to pay more, no terms of service changing overnight.

Welcome to your private cloud.