Setup nextcloud with s3 as primary storage
Problem
Setup nextcloud instance on your own server behind a reverse proxy (nginx) and use s3 as the primary storage
Solution
1, Create nextcloud folder
This folder will be used for saving nextcloud files and logs, I use /home/project/nextcloud as example. Inside create 2 sub folders data and logs
2, Run nextcloud docker
Create a rundocker.sh shell:
1 |
|
Here we run the nextcloud container at port 5808, and map the /home/project/nextcloud/data folder to /var/www/html inside the container. Run this script:
1 | $ bash rundocker.sh |
3, Setup nginx:
nextcloud.conf
1 | server { |
Load this config to sites-enabled and restart nginx
4, Change nextcloud config
cd to /home/project/nextcloud/data/config folder, find the config.php file, then add:
1 | 'trusted_proxies' => |
Here the trusted_proxies is the docker network, the default network is 172.16, but you can see your nextcloud container’s IP with command:
1 | $ docker inspect container_id | grep IPAddr |
If the IP address is “172.17.0.x”, then you should add the 2nd line “172.17.0.0/12”. If it is “172.18.0.x”, then you should add the 18.
The overwriteprotocol is also important. The nextcloud container is running under plain “http”, and since your domain is most likely running under “https://“ like “https://drive.yourdomain.com", here we need to set “overwriteprotocol” to “https”.
The objectstore part is the key to use s3 as nextcloud’s primary storage. I am using wasabi as example, you can use any s3 compatible storage system, just change the bucket name, key, secret, region and hostname.
Lastly, save this config.php file and visit your custom domain https://drive.yourdomain.com, it should work now.