# Nextcloud Complete Stack

> Full Nextcloud deployment with collabora, talk, and office suite.

- Category: Storage & Backup
- Difficulty: advanced
- Components: nextcloud, nginx, mariadb, redis, collabora, coturn
- Tags: nextcloud, file-sharing, collaboration, office, storage
- Source: https://docker.recipes/storage/nextcloud-complete

## Overview

Nextcloud is a comprehensive self-hosted productivity platform that emerged as a fork of ownCloud in 2016, providing organizations with complete control over their file storage, collaboration, and communication infrastructure. Built to replace proprietary cloud services like Google Workspace or Microsoft 365, Nextcloud offers file synchronization, collaborative document editing, video conferencing, calendar management, and an extensive app ecosystem while maintaining data sovereignty and privacy.

This complete stack orchestrates six critical components to deliver enterprise-grade Nextcloud functionality: NGINX serves as the high-performance reverse proxy handling SSL termination and static file delivery, MariaDB provides robust relational database storage for user data and metadata, Redis accelerates performance through in-memory caching and session management, Collabora Online enables real-time collaborative document editing within the browser, and Coturn operates as a TURN server ensuring reliable peer-to-peer connections for Nextcloud Talk video calls even behind NAT and firewalls.

Organizations seeking complete digital sovereignty, educational institutions requiring GDPR-compliant collaboration tools, and businesses needing integrated file storage with office suite capabilities will find this stack invaluable. The combination delivers production-ready functionality that rivals commercial cloud platforms while maintaining full administrative control, making it ideal for privacy-conscious enterprises, government agencies, healthcare organizations bound by data residency requirements, and technical teams building internal collaboration infrastructure.

## Features

- File synchronization across desktop, mobile, and web clients with conflict resolution
- Real-time collaborative document editing through integrated Collabora Online office suite
- Nextcloud Talk video conferencing with TURN server support for NAT traversal
- High-performance file serving via NGINX with HTTP/2 support and static asset optimization
- MariaDB Galera-ready database backend with READ-COMMITTED isolation for Nextcloud compatibility
- Redis-powered file locking, session storage, and distributed caching for multi-instance deployments
- App ecosystem integration supporting calendar, contacts, mail, and 200+ community applications
- End-to-end encryption for files with server-side encryption and client-side key management

## Use cases

- Enterprise file sharing replacement for Dropbox Business or Google Drive with on-premises data control
- Educational institutions providing students and faculty with FERPA-compliant collaboration tools
- Healthcare organizations requiring HIPAA-compliant document storage and secure patient data sharing
- Government agencies needing classified data handling with air-gapped deployment capabilities
- Remote teams requiring integrated video conferencing, file sharing, and collaborative document editing
- Software development teams needing project file storage with version control and team communication
- Small businesses seeking cost-effective office suite alternatives with customer data privacy

## Prerequisites

- Minimum 4GB RAM recommended (2GB+ for Nextcloud, 1GB+ for MariaDB, 512MB+ for Redis/Collabora)
- Available ports 80, 443, 9980 for web services and 3478 TCP/UDP for TURN server functionality
- Valid SSL certificates and domain name configuration for trusted domain security
- Docker Compose version 3.8+ with volume mount permissions for persistent data storage
- Basic understanding of Nextcloud administration for app installation and user management
- Network firewall configuration allowing WebRTC traffic for Nextcloud Talk functionality

## docker-compose.yml

```yaml
services:
  nextcloud:
    image: nextcloud:28-fpm
    container_name: nextcloud
    environment:
      - MYSQL_HOST=db
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=${DB_PASSWORD}
      - REDIS_HOST=redis
      - NEXTCLOUD_TRUSTED_DOMAINS=${NEXTCLOUD_DOMAIN}
      - OVERWRITEPROTOCOL=https
    volumes:
      - nextcloud-html:/var/www/html
      - nextcloud-data:/var/www/html/data
    depends_on:
      - db
      - redis
    networks:
      - nextcloud-network
    restart: unless-stopped

  nginx:
    image: nginx:alpine
    container_name: nextcloud-nginx
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - nextcloud-html:/var/www/html:ro
    ports:
      - "80:80"
      - "443:443"
    depends_on:
      - nextcloud
    networks:
      - nextcloud-network
    restart: unless-stopped

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

  redis:
    image: redis:7-alpine
    container_name: nextcloud-redis
    volumes:
      - redis-data:/data
    networks:
      - nextcloud-network
    restart: unless-stopped

  collabora:
    image: collabora/code:latest
    container_name: nextcloud-collabora
    environment:
      - domain=${NEXTCLOUD_DOMAIN}
      - username=admin
      - password=${COLLABORA_PASSWORD}
      - extra_params=--o:ssl.enable=false --o:ssl.termination=true
    cap_add:
      - MKNOD
    ports:
      - "9980:9980"
    networks:
      - nextcloud-network
    restart: unless-stopped

  coturn:
    image: coturn/coturn:latest
    container_name: nextcloud-coturn
    command: -n --log-file=stdout --listening-ip=0.0.0.0 --listening-port=3478 --realm=${NEXTCLOUD_DOMAIN} --static-auth-secret=${TURN_SECRET}
    ports:
      - "3478:3478/tcp"
      - "3478:3478/udp"
    networks:
      - nextcloud-network
    restart: unless-stopped

volumes:
  nextcloud-html:
  nextcloud-data:
  mariadb-data:
  redis-data:

networks:
  nextcloud-network:
    driver: bridge
```

## .env

```bash
# Nextcloud Complete
NEXTCLOUD_DOMAIN=nextcloud.example.com
DB_PASSWORD=secure_nextcloud_password
DB_ROOT_PASSWORD=secure_root_password
COLLABORA_PASSWORD=collabora_admin_password

# Generate with: openssl rand -hex 32
TURN_SECRET=your_turn_secret_here
```

## Usage notes

- Nextcloud at https://localhost
- Collabora Office integration
- Nextcloud Talk with TURN server
- Run occ commands: docker exec nextcloud php occ
- Enable apps from admin panel

## Troubleshooting

- Trusted domain error on first access: Add your domain to NEXTCLOUD_TRUSTED_DOMAINS environment variable and restart container
- Collabora connection failed in Nextcloud: Verify port 9980 accessibility and set Collabora server URL to http://collabora:9980 in Nextcloud Office settings
- Video calls failing to connect: Check coturn container logs for TURN authentication and ensure UDP port 3478 is properly forwarded through firewalls
- Database connection errors during setup: Confirm MariaDB container fully initialized by checking logs for 'ready for connections' before starting Nextcloud
- Redis connection warnings in Nextcloud logs: Verify Redis container accessibility and configure file locking in Nextcloud config.php with 'filelocking.enabled' => true
- File upload failures or timeouts: Increase PHP memory limits and max file size in Nextcloud container or adjust NGINX client_max_body_size directive

