What is Nextcloud?

Nextcloud is a self-hosted productivity platform that provides file storage, synchronization, and collaboration tools. It is the open-source alternative to services like Google Drive, Dropbox, and Office 365.

Key Features

  • File Storage & Sync: Access files from anywhere
  • Calendar & Contacts: Personal information management
  • Office Suite: Online document editing
  • Video Calls: Built-in communication tools
  • App Ecosystem: Extensible with hundreds of apps
  • Security: End-to-end encryption options

MCT Services Nextcloud Configuration

Our production Nextcloud setup:

version: "3.8"

services:
  nextcloud:
    image: nextcloud:apache
    container_name: nextcloud
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - nextcloud_data:/var/www/html
      - ./nextcloud/config:/var/www/html/config
      - ./nextcloud/custom_apps:/var/www/html/custom_apps
      - ./nextcloud/data:/var/www/html/data
      - ./nextcloud/themes:/var/www/html/themes
    environment:
      - MYSQL_HOST=mariadb
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=
      - NEXTCLOUD_ADMIN_USER=admin
      - NEXTCLOUD_ADMIN_PASSWORD=
      - NEXTCLOUD_TRUSTED_DOMAINS=nextcloud.mct.local localhost
      - OVERWRITEPROTOCOL=https
      - OVERWRITEHOST=nextcloud.mct.local
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.nextcloud.rule=Host(`nextcloud.mct.local`)"
      - "traefik.http.routers.nextcloud.tls=true"
      - "traefik.http.services.nextcloud.loadbalancer.server.port=80"
    depends_on:
      - mariadb
      - redis

  mariadb:
    image: mariadb:10.11
    container_name: mariadb
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=
    volumes:
      - mariadb_data:/var/lib/mysql
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW

  redis:
    image: redis:alpine
    container_name: redis
    restart: unless-stopped
    command: redis-server --requirepass 

volumes:
  nextcloud_data:
  mariadb_data:

Directory Structure

Organize your Nextcloud deployment:

nextcloud/
├── docker-compose.yml
├── .env
├── config/
│   ├── config.php
│   └── apps.config.php
├── custom_apps/
├── data/
│   └── [user files]
├── themes/
└── backups/
    ├── database/
    └── files/

Environment Variables (.env file)

# Database Configuration
MYSQL_ROOT_PASSWORD=secure_root_password_here
NEXTCLOUD_DB_PASSWORD=secure_nextcloud_db_password

# Nextcloud Admin
NEXTCLOUD_ADMIN_PASSWORD=secure_admin_password

# Redis Cache
REDIS_PASSWORD=secure_redis_password

# Backup Configuration
BACKUP_RETENTION_DAYS=30

Initial Configuration

After deployment, configure these essential settings:

1. Basic Settings

  • Admin Account: Create strong admin credentials
  • Data Directory: Verify data location
  • Database: Confirm MariaDB connection
  • Trusted Domains: Add your domain names

2. Performance Optimization

  • Memory Cache: Configure Redis for caching
  • Background Jobs: Set up cron for maintenance
  • File Locking: Enable for data integrity
  • Preview Generation: Configure image previews

3. Security Configuration

  • HTTPS: Force SSL connections
  • Two-Factor Auth: Enable 2FA for admin
  • Brute Force Protection: Configure rate limiting
  • File Access Control: Set proper permissions

Essential Apps to Install

  • Calendar: Personal calendar management
  • Contacts: Address book synchronization
  • Mail: Email client integration
  • Notes: Simple note-taking
  • Tasks: Todo list management
  • Deck: Kanban-style project management
  • OnlyOffice: Advanced document editing

Client Setup

Configure clients for seamless access:

Desktop Sync Client

  • Download from nextcloud.com/install
  • Configure server URL: https://nextcloud.mct.local
  • Select folders to synchronize
  • Configure bandwidth limits if needed

Mobile Apps

  • Nextcloud Files: File access and sync
  • Nextcloud Talk: Video calls and chat
  • Nextcloud Notes: Note synchronization

Backup Strategy

Implement comprehensive backup procedures:

#!/bin/bash
# Nextcloud backup script

# Variables
BACKUP_DIR="/backups/nextcloud"
DATE=20251106_085218

# Create backup directory
mkdir -p "/"

# Backup database
docker exec mariadb mysqldump -u root -p nextcloud > "//nextcloud_db.sql"

# Backup data directory
tar -czf "//nextcloud_data.tar.gz" ./nextcloud/data

# Backup configuration
cp -r ./nextcloud/config "//"

# Cleanup old backups (keep 30 days)
find "" -type d -mtime +30 -exec rm -rf {} +

Troubleshooting Common Issues

Database Connection Errors

# Check database container
docker logs mariadb

# Test database connection
docker exec nextcloud php occ db:check-connection

File Permission Issues

# Fix ownership
sudo chown -R www-data:www-data ./nextcloud/data
sudo chmod -R 755 ./nextcloud/data

Memory and Performance

# Check system status
docker exec nextcloud php occ status

# Run maintenance tasks
docker exec nextcloud php occ maintenance:mode --on
docker exec nextcloud php occ db:add-missing-indices
docker exec nextcloud php occ maintenance:mode --off

Practical Exercise

Task: Deploy and configure Nextcloud

  1. Set up Docker Compose configuration
  2. Deploy Nextcloud with MariaDB and Redis
  3. Complete initial setup wizard
  4. Install and configure essential apps
  5. Set up desktop sync client
  6. Create backup script and test restore
  7. Configure HTTPS with Traefik integration
Last modified: Thursday, 6 November 2025, 8:52 AM