Install Nextcloud with Docker Compose

white sky photography

Install Nextcloud with Docker compose

docker-compose.yml

version: '2'

services:
  db:
    image: mariadb:10.5
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - /home/dock/nextcloud/db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=nextclouddb
      - MYSQL_PASSWORD=nextclouddb
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    restart: unless-stopped

  app:
    image: nextcloud
    restart: always
    ports:
      - 5001:80
    links:
      - db
    volumes:
      - /home/dock/nextcloud/nextcloud:/var/www/html
    environment:
      - MYSQL_PASSWORD=nextclouddb
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db
    restart: unless-stopped

Run:

docker-compose up -d

Expose your Nextcloud to the internet – Nginx Proxy host config:

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

        location / {
                proxy_pass http://localhost:5001;

                proxy_set_header X-Forwarded-Host     $host;
                proxy_set_header X-Forwarded-Server   $host;
                proxy_set_header X-Real-IP            $remote_addr;
                proxy_set_header X-Forwarded-For      $remote_addr;
                proxy_set_header X-Forwarded-Proto    $scheme;
                proxy_set_header X-Forwarded-Protocol $scheme;
                proxy_set_header X-Forwarded-Port     443;
                proxy_set_header Forwarded "for=$remote_addr;proto=$scheme";

                proxy_set_header Host                 $host;

                proxy_redirect  off;
                proxy_buffering off;

                proxy_http_version 1.1;
                proxy_set_header Upgrade    $http_upgrade;
                proxy_set_header Connection "upgrade";

                proxy_pass_header Authorization;
                proxy_request_buffering off;
                client_max_body_size 0;
                proxy_read_timeout  36000s;
                proxy_ssl_session_reuse off;

                fastcgi_param HTTPS on;
                fastcgi_param REQUEST_SCHEME https;
        }

Leave a Comment

Your email address will not be published.