Run this bootstrap script. It will create many entries in /etc/hosts
, like nextcloud.local
, stable16.local
, etc. If you use docker-hostmanager you can remove these entries later.
git clone https://github.com/juliushaertl/nextcloud-docker-dev
cd nextcloud-docker-dev
./bootstrap.sh
It will also create a .env
file and set some variables. Set PROXY_PORT_HTTPS
to be the gateway of DOCKER_SUBNET
and the 443 port (I tried different port but it doesn't work). Change PROXY_PORT_HTTP
if needed too.
...
DOCKER_SUBNET=192.168.21.0/24
...
PROXY_PORT_HTTP=8070
PROXY_PORT_HTTPS=192.168.21.1:443
If you already have a service in port 443, make sure that other services are not listening to port 443 in that IP (or all IPs as *:443
).
sudo lsof -i -P -n | grep LISTEN | grep :443
If you have *:443
, check the NGINX configuration below. Stop NGINX for now or next step will fail.
Edit docker-compose.yml
so that the network that will be created has an hyphen, not underscore (underscores are not resolved by systemd-resolved
.
networks:
default:
name: ${COMPOSE_PROJECT_NAME:-master}-default
ipam:
driver: default
config:
- subnet: ${DOCKER_SUBNET:-192.168.21.0/24}
Run docker compose, it is going to download some docker images and setup Nextcloud in your Docker.
docker compose up -d nextcloud
Configure your DNS server to respond myhostname.local
to your WiFi/LAN IP 192.168.x.y
.
Tried to access both https://nextcloud.local and http://nextcloud.local . HTTPS was giving SSL error, HTTP was returning 503.
I found this discussion https://github.com/juliushaertl/nextcloud-docker-dev/discussions/251#discussioncomment-8386204, which led to https://github.com/arawa/nextcloud-docker-dev/blob/doc/improve-getting-started/docs/containers/ssl.md .
From there, I copied this command to create a self-signed SSL certificate.
# cd nextcloud-docker-dev
cd data/ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout nextcloud.local.key -out nextcloud.local.crt
# and
docker compose restart proxy
Now I can access https://nextcloud.local, first password is admin/admin, change it later inside Nextcloud.
Change /etc/hosts
entry for nextcloud.local
, intead of 127.0.0.1, put proxy subnet IP. If you will use DNSMasq, add another entry for dev.nextcloud.local
with your WiFI/LAN IP. If you will use PiHole you will add dev.nextcloud.local
in its CNAME. If you use docker-hostmanager it will create an entry in /etc/hosts
for you.
docker inspect master-proxy-1 | grep IPAddress
/etc/hosts
127.0.0.1 localhost
192.168.0.12 your_hostname.local
...
192.168.21.4 nextcloud.local
192.168.0.12 dev.nextcloud.local # only if using dnsmasq
...
Not fully tested, probably need to edit /etc/hosts
Install dnsmasq
so your local server can resolve dev.nextcloud.local
in your local LAN.
Configure /etc/dnsmaqs.conf
and .
/etc/dnsmasq.conf
domain-needed
bogus-priv
no-resolv
# server - set to your local router, or to a public DNS like 8.8.8.8 (google) or 1.1.1.1 (cloudflare)
server=192.168.0.1
# address - tell dnsmasq that any domain xyz.local resolves to your local IP
# 192.168.0.12 is the IP of your system in your LAN (`hostname -I` or `ip a`)
# I set it, but it doesn't work if `/etc/hosts` is not set, the documentation says it should work without `/etc/hosts`
address=/.local/192.168.0.12
# listen-address - set it to all your system IP, check `hostname -I`, Docker creates many Networks, each gets an IP range
# if you have Virt-Manager, exclude the virt-manager range
listen-address=::1,127.0.0.1,192.168.0.12,x.x.x.x,y.y.y.y,z.z.z.z
expand-hosts
cache-size=1000
Add one entry in DNS Records with Domain your_hostname.local
and IP 192.168.0.12
(your WiFi/LAN IP).
Add one CNAME entry with Domain dev.nextcloud.local
and Target your_hostname.local
.
If using PiHole docker version, another option is to mount your local /etc/hosts
into PiHole.
-v '/etc/hosts:/etc/hosts:ro' # ro - read only
Need to setup NGINX as reverse proxy.
If you have existing service, make sure it is not listening to all IPs. Set it to listen only your WiFi/LAN IP.
The new service listens to the CNAME dev.nextcloud.local
in port 443 and proxy pass it to nextcloud.local
defined in /etc/hosts
.
# existing service
server {
...
listen 192.168.0.12:443 ssl; # putting 192.168.0.12 here tells nginx to listen 443 only for this IP
...
}
# new service
# https://github.com/nextcloud/all-in-one/blob/main/reverse-proxy.md#nginx
# AIO proxy is served in port 11000, Dev is served in port 443
server {
server_name dev.nextcloud.local; # /etc/hosts - 192.168.0.12 dev.nextcloud.local
listen 192.168.0.12:443 ssl http2; # my WiFi/LAN IP
resolver 192.168.0.12 ipv6=off valid=10s; # my local DNS resolver
set $dev_proxy "http://nextcloud.local.master-default"; # /etc/hosts - added by docker-hostmanager
location / {
proxy_pass $dev_proxy$request_uri;
proxy_redirect $dev_proxy$request_uri $request_uri; # don't update user's browser URL
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme; # this causes the URL in the browser to change to nextcloud.local, causing problems when on LAN
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header Host nextcloud.local; # this has to be nextcloud.local, not $host, neither nextcloud.local.master-default
add_header BRC_host $host;
add_header BRC_http_host $http_host;
add_header BRC_remote_addr $remote_addr;
add_header BRC_server_port $server_port;
add_header BRC_request_uri $request_uri;
add_header BRC_proxy_host $proxy_host;
client_body_buffer_size 512k;
proxy_read_timeout 86400s;
client_max_body_size 0;
# Websocket
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
ssl_certificate /etc/nginx/ssl/nextcloud.local.crt;
ssl_certificate_key /etc/nginx/ssl/nextcloud.local.key;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305;
ssl_prefer_server_ciphers on;
# main is set at /etc/nginx/conf.d/log_fmt.conf
access_log /var/log/nginx/dev.proxy.access.log main;
error_log /var/log/nginx/dev.proxy.error.log warn;
}
Open firewall ports.
sudo ufw allow from 192.168.0.0/16 to any port 443
Nextcloud will be accessible through https://dev.nextcloud.local !
Install the app from Admin page.
Can't setup models 1,2,3,4 due to problems on install/compile PDlib in the Nextcloud Docker container, some error with DLIB GUI. Solution is to deploy another docker container for the model analysis.
External Facerecognition https://github.com/matiasdelellis/facerecognition-external-model/
Use image v1
, not v0.2.0
.
Make sure API_KEY
is cleared.
# cd nextcloud-docker-dev
# cd data/ssl
openssl rand -base64 32 > api.key
docker run -d -p 5000:5000 -v ./api.key:/app/api.key -e API_KEY= --name facerecognition matiasdelellis/facerecognition-external-model:v1
You will need the value to configure Nextcloud, save it somewhere.
# cd nextcloud-docker-dev
# cd data/ssl
cat ./api.key
Add facerecognition
container to master-default
network created by docker compose
above.
docker network connect master-default facerecognition
Verify the new subnet IP
docker network inspect master-default | grep Gateway
Verify the facerecognition IP that belongs to the subnet above (there wil be more than one IP, check the correct subnet one).
docker inspect facerecognition | grep IPAdd
Configure Nextcloud instance to use External Facerecognition.
Enter container console.
docker exec -it master-nextcloud-1 /bin/bash
Test if Nextcloud can access External Facerecognition. If not, check your docker networks, they must be in the same subnet (new or existing).
# curl -k 192.168.21.7:5000/welcome
# if they are in the same subnet, you can use the container name as hostname
curl facerecognition:5000/welcome
Configure with these commands:
# cd /var/www/html
# sudo -u www-data ./occ config:system:set facerecognition.external_model_url --value 192.168.21.7:5000
# if they are in the same subnet, you can use the container name as hostname
sudo -u www-data ./occ config:system:set facerecognition.external_model_url --value facerecognition:5000
sudo -u www-data ./occ config:system:set facerecognition.external_model_api_key --value abc123 # file api.key created above
Configure PHP memory limit in Nextcloud container.
apt update
apt install nano
nano /usr/local/etc/php/conf.d/nextcloud.ini
# set memory limit to a value greater than 682.7 MB (value required by Facerecognition)
# memory_limit=2048M
Install Facerecognition from Nextcloud admin page.
Configure Facerecognition app.
occ face:setup --model 5
occ face:setup -M 2048M
For now, External Facerecognition need a small change in facerecognition-external-model.py
.
if 'API_KEY' in os.environ and os.environ['API_KEY']: