Skip to content

Instantly share code, notes, and snippets.

@kaxing
Last active October 10, 2022 07:58
Show Gist options
  • Save kaxing/debd5af276cfaec7ffc214adf8f5629d to your computer and use it in GitHub Desktop.
Save kaxing/debd5af276cfaec7ffc214adf8f5629d to your computer and use it in GitHub Desktop.
Nextcloud on home server with docker

Hardward: x86_64, 2 core CPU, 4GB ram OS: Ubuntu Linux 20.04 LTS

The idea is to set up a file server for sharing files in between small group of people.

On Networking

The server is behind a router from ISP, so I had to configure the NAT Port-Forwarding to the local IP. And since there is no static IP, I also had to use script like ddns-updater.

Installation

A really nice dockerfile example can be find here: Nginx + MariaDB + PHP-FPM + letsencrypt: link to the example from Nextcloud

Some quick troubleshootings

Device login problem with authentication

Add following lines to the config.php, ref.,

# inside app container, /var/www/html/config/config.php:
'overwrite.cli.url' => 'https://your.domain.name',
'overwriteprotocol' => 'https',
File permission related errors

First aid, go into app container and check the group and user of /var/www/html/* My ultimate lazy solutions is to chmod all files to 775, ref.

For Email/SMTP login

Just choose STARTTLS for some reason other methods will not complain with DMARC policy.

Reference setting using OCC commdn:

this: https://github.com/liquidinvestigations/node/blob/master/templates/nextcloud-setup.sh

VIRTUAL_HOST=your.domain.name
LETSENCRYPT_HOST=your.domain.name
LETSENCRYPT_EMAIL=your@email.address
# NC_overwriteprotocol="https"
version: '3'
services:
db:
image: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=nextcloud
env_file:
- db.env
redis:
image: redis:alpine
restart: always
app:
image: nextcloud:fpm-alpine
restart: always
volumes:
- nextcloud:/var/www/html
environment:
- MYSQL_HOST=db
- REDIS_HOST=redis
env_file:
- db.env
depends_on:
- db
- redis
web:
# user: root
build: ./web
restart: always
volumes:
- nextcloud:/var/www/html:ro
environment:
- VIRTUAL_HOST=${VIRTUAL_HOST}
# - LETSENCRYPT_HOST=${LETSENCRYPT_HOST}
# - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
depends_on:
- app
networks:
- proxy-tier
- default
cron:
image: nextcloud:fpm-alpine
restart: always
volumes:
- nextcloud:/var/www/html
entrypoint: /cron.sh
depends_on:
- db
- redis
proxy:
build: ./proxy
restart: always
ports:
- 80:80
- 443:443
# labels:
# com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
volumes:
- certs:/etc/nginx/certs:ro
- vhost.d:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
# - acme:/etc/acme.sh
networks:
- proxy-tier
depends_on:
- omgwtfssl
# - letsencrypt-companion
# letsencrypt-companion:
# image: jrcs/letsencrypt-nginx-proxy-companion
# restart: always
# volumes:
# - certs:/etc/nginx/certs
# - vhost.d:/etc/nginx/vhost.d
# - html:/usr/share/nginx/html
# - /var/run/docker.sock:/var/run/docker.sock:ro
# - acme:/etc/acme.sh
# networks:
# - proxy-tier
# depends_on:
# - proxy
# self signed
omgwtfssl:
image: paulczar/omgwtfssl
restart: "no"
volumes:
- certs:/certs
environment:
- SSL_SUBJECT=${VIRTUAL_HOST}
- CA_SUBJECT=${VIRTUAL_HOST}
- SSL_KEY=/certs/${VIRTUAL_HOST}.key
- SSL_CSR=/certs/${VIRTUAL_HOST}.csr
- SSL_CERT=${VIRTUAL_HOST}.crt
networks:
- proxy-tier
volumes:
db:
driver: local
nextcloud:
driver: local
certs:
driver: local
vhost.d:
driver: local
html:
driver: local
networks:
proxy-tier:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment