Self-hosting Nextcloud with Dokku and s3 compatible storage
source link: https://vitobotta.com/2022/03/11/self-hosting-nextcloud-with-dokku-and-s3-compatible-storage/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
For those who are not familiar with Dokku, I recommend you read the previous post first or the official site. In short, it's an awesome open source PaaS similar to Heroku (albeit limited to one server).
If you are not familiar with Nextcloud, it's an feature-rich open source platform for file sharing, syncing (with apps for most operating systems and devices) and collaboration. It offers the ability to install "apps" with which you can replicate many of the features you can have with paid solutions like Google Workspace. Learn more here.
I particularly like Nextcloud because by self hosting I don't have to worry about privacy as much as I would have for example with Google. Plus it can be much cheaper than paid options like Google or Dropbox (speaking of file sharing/syncing), depending on where and how you self host it.
Let's see how to deploy it using Dokku on a Linux server. In this post I'll show how you can use an s3 compatible object storage service as the primary storage for Nextcloud - I am testing this with Wasabi at the moment. It's an awesome option so you don't need a server with a ton of local storage if you need to store a lot of data.
Creating the app
dokku apps:create nextcloud
dokku git:from-image nextcloud nextcloud:23.0.2-apache
Mounting the local storage
First, create a directory where to store this configuration; Dokku by default uses `/var/lib/dokku/data/storage` as a container for directories to "mount" inside applications. So let's create a subdirectory for Nextcloud:
mkdir -p /var/lib/dokku/data/storage/nextcloud
dokku storage:mount nextcloud /var/lib/dokku/data/storage/nextcloud:/var/www/html
Supporting services
dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres dokku postgres:create nextcloud-postgres dokku postgres:link nextcloud-postgres nextcloud
dokku plugin:install https://github.com/dokku/dokku-redis.git redis dokku redis:create nextcloud-redis dokku redis:link nextcloud-redis nextcloud
Next, we need to add some custom configuration to Nextcloud. Check which passwords and hosts Dokku has set for Postgres and Redis with the aforementioned environment variables, because Nextcloud expects different variables:
dokku config:show nextcloud
dokku config:set nextcloud \ DOKKU_LETSENCRYPT_EMAIL=<your email address to issue a certificate with Let's Encrypt> \ POSTGRES_DB=nextcloud \ POSTGRES_USER=postgres \ POSTGRES_PASSWORD=<postgres password> \ POSTGRES_HOST=<the postgres host> \ REDIS_HOST=<redis host> \ REDIS_HOST_PASSWORD=<redis password> \ SMTP_HOST=<smtp host> \ SMTP_PORT=587 \ SMTP_SECURE=tls \ SMTP_AUTHTYPE=PLAIN \ SMTP_NAME=<smtp username> \ SMTP_PASSWORD=<smtp password> \ MAIL_FROM_ADDRESS=cloud \ # or whichever name you want to receive email notifications from; note that this should be set to the name part only of an email address MAIL_DOMAIN=<email domain> \ OVERWRITEPROTOCOL=https \ NEXTCLOUD_TRUSTED_DOMAINS=<your full nextcloud domain, e.g. cloud.mydomain.com> \ NEXTCLOUD_ADMIN_USER=<first admin username> \ NEXTCLOUD_ADMIN_PASSWORD=<first admin password> \ OBJECTSTORE_S3_BUCKET=true \ OBJECTSTORE_S3_SSL=true \ OBJECTSTORE_S3_USEPATH_STYLE=false \ OBJECTSTORE_S3_LEGACYAUTH=false \ OBJECTSTORE_S3_AUTOCREATE=false \ OBJECTSTORE_S3_BUCKET=<s3 bucket to use as primary storage> \ OBJECTSTORE_S3_KEY=<s3 access key> \ OBJECTSTORE_S3_SECRET=<s3 secret key> \ OBJECTSTORE_S3_REGION=<s3 region> \ OBJECTSTORE_S3_HOST=<s3 endpoint hostname> \ OBJECTSTORE_S3_PORT=443
- ensures that we use the Postgres and Redis instances we created earlier
- configures an SMTP provider so we can have Nextcloud send us notifications when for example sharing files and folders; if you don't have a provider of choice, I recommend Mailplace since it's very cheap and reliable
- configures an s3 bucket as primary storage for user data; I recommend Wasabi for this since it only charges for the amount of data stored. Other providers charge for API requests too, and Nextcloud can make quite many of them
- creates the first admin user
Certificate
dokku domains:add nextcloud cloud.mydomain.com dokku letsencrypt:enable nextcloud
Increasing the max upload size for browser transfers
mkdir -p /home/dokku/nextcloud/nginx.conf.d/ echo 'client_max_body_size 5120m;' > /home/dokku/nextcloud/nginx.conf.d/upload.conf service nginx reload
Done. Now open the Nextcloud domain in your browser and login as the first admin user to configure the rest.
Wrapping up
Recommend
-
34
-
16
Luminus provides a great way to get up and running with a Clojure web application. However, building your app is only half the work. Once you've got your app working, the next step is to host it somewhere so that the user...
-
5
Optimize Dokku Deployment Speed for Ruby on Rails with Dockerfile Updated Jun 28, 2019 12 comments 6 minute read
-
3
Hosting Static Site on Dokku with Free Cloudflare CDN and SSL Updated May 21, 2018 4 comments 5 minute read ...
-
3
How to Migrate a Ruby on Rails App from Heroku to Dokku Updated May 18, 2020 14 comments 8 minute read ...
-
4
An easy way to deploy web appsDokku - An easy way to deploy web apps 21 Feb 2016 TL;DR Use easy-to-setup Dokku and push your code via git to have it deployed in a docker...
-
12
Haproxy, Nginx and Dokku Posted on: January 04, 2021 342 Words Takes 2 minutes to read I just finished setting up a wordpress site for...
-
3
Introduction Various services exist providing cloud storage, file syncing/sharing and collaboration, with the most popular ones being Dropbox, Google Dr...
-
1
Create Your Own Low-Cost Cloud Storage App with Sia and Nextcloud August 6, 2017 16-minute read In today’s post, I’m going to show you how to set up your own cloud storage...
-
1
Ask HN: Self-hosting in 2023: Nextcloud on Linode, or...?
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK