How to deploy NextCloud in your Linux Server with docker and SSL

Whenever you create your account and retailer your paperwork, photographs, and so on in Google drive or dropbox, you aren’t the grasp of your knowledge. Usually, we are saying that we use Google or Microsoft one drive at no cost but it surely’s not free. We pay for these free areas with the private knowledge they collected. It’s the place NextCloud is available in. In easy phrases, Nextcloud is your cloud infrastructure beneath your management.



What’s NextCloud ?

NextCloud is open-source software program that lets you run your personnel cloud service like dropbox. It offers you entry to all of your information wherever you’re. It lets you share and collaborate on paperwork, ship and obtain e mail, handle your calendar and have video chats. You may set up the Nextcloud server software program free in your Linux server and the consumer’s software program in your Home windows, OS X, or Linux machine, Android, and IOS cell phone.

The principle disadvantage right here is you might want to pay to your Linux server to your VPS supplier and you’ll be liable for your server upkeep until your select Nextcloud Enterprise which comes with the help. For instance, should you select the Contabo supplier, you’ll be able to have your totally useful cloud answer with 200GB SSD, 8GO of RAM, and 4vCPU for less than $6.99 a month.



Pre-requisite earlier than the set up of Nextcloud

As we’ll deploy our NextCloud occasion with docker, you might want to have:

  • A Linux Server with SSH and root entry
  • Docker and docker-compose put in on that server
  • A website title pointed to that server



Deployment of NextCloud

POSTGRES_PASSWORD=yourdbstrongpassword
POSTGRES_DB=nextcloud
POSTGRES_USER=nextcloud
Enter fullscreen mode

Exit fullscreen mode

db.env file

model: "3.9"

providers:
  nextcloud_db:
    picture: postgres:alpine
    restart: all the time
    volumes:
      - nextcloud_dbdata:/var/lib/postgresql/knowledge
    env_file:
      - db.env

  redis:
    picture: redis:alpine
    restart: all the time

  nextcloud_web:
    picture: nextcloud:apache
    restart: all the time
    volumes:
      - nextcloud:/var/www/html
    surroundings:
      - VIRTUAL_HOST=cloud.yourdomain.com
      - LETSENCRYPT_HOST=cloud.yourdomain.com
      - LETSENCRYPT_EMAIL=yourmail # <===== For let's encrypt
      - POSTGRES_HOST=nextcloud_db
      - REDIS_HOST=redis
    env_file:
      - db.env
    depends_on:
      - nextcloud_db
      - redis

  cron:
    picture: nextcloud:apache
    restart: all the time
    volumes:
      - nextcloud:/var/www/html
    entrypoint: /cron.sh
    depends_on:
      - nextcloud_db
      - redis

volumes:
  nextcloud_dbdata:
  nextcloud:

#Use this configuration in manufacturing with nginx-proxy container
networks:
  default:
    exterior:
      title: nginx-proxy
Enter fullscreen mode

Exit fullscreen mode

docker-compose.yml file

Login to your Linux server and sort the next command:

mkdir nextcloud && cd nextcloud
nano db.env
Enter fullscreen mode

Exit fullscreen mode

Copie the content material of the db.env within the above GitHub gist and paste it into the newly created file. After this, create a docker-compose.yml file and duplicate the content material of the docker-compose.yml within the above Github gist and paste it into.

Observe: Don’t overlook the change the surroundings variables VIRTUAL_HOST and LETSENCRYPT_HOST together with your area title and LETSENCRYPT_EMAIL together with your e mail tackle.

Now, it’s time to create the docker community that will be used to drive safe site visitors to our Nextcloud occasion via our area title.

docker community create nginx-proxy
Enter fullscreen mode

Exit fullscreen mode

Then let’s begin our Nextcloud occasion.

docker-compose up --build -d
Enter fullscreen mode

Exit fullscreen mode

Our Nextcloud occasion is now operating however is just not accessible from the web. We are going to now configure Nginx-proxy to drive site visitors to our Nextcloud occasion. We are going to clarify our docker-compose file after making our occasion totally useful.



Set up of Nginx-proxy and acme-compagnon

Nginx proxy is a container operating Nginx and docker-gen which is a service that generates reverse proxy configs for Nginx and reloads Nginx when containers are began or stopped.

This container is mounted on a docker socket to seize all occasions created by docker to have the ability to proxied any container with an env variable VIRTUAL_HOST outline. All containers that wish to be proxied by Nginx-proxy should be related to the identical community with it. To know extra about Nginx-proxy, visit the GitHub of the project.

ACME-compagnon is a compagnon for Nginx-proxy accountable to automate the creation, renewal, and use of SSL certificates for proxied Docker containers via ACME protocol. For extra details about acme-compagnon, visit the GitHub of the project.

I’ve a ready-to-use template for Nginx-proxy in my repository. You simply must clone and run it. I additionally use this template in all my tasks. With this configuration, it’s straightforward to make issues work in lower than a minute. Simply use the next command.

cd ~
git clone https://gitlab.com/tderick/nginx-proxy-conf.git 
docker-compose up --build -d
Enter fullscreen mode

Exit fullscreen mode

Now, your Nextcloud occasion is operating, and you’ll entry it by way of your area title.

NextCloud first page

Whenever you set up Nextcloud, it doesn’t include an admin account by default. That you must create it. Simply fill within the type on the primary web page and hit the set up button. Don’t put e mail as username. should you do, you’ve the next error:

Error page when we use email as username

After placing in a username and password, we’ll arrive on the following web page itemizing the really helpful apps to put in in our occasion.

Recommend app to be installed in our nextcloud instance

We are able to see there are purposes for:

  • Calendar
  • Contacts
  • Mail
  • On-line version and collaboration

We are going to set up different purposes later. Simply hit the set up really helpful apps button.

Nextcloud Dashboard

Our nextcloud occasion is now put in and able to use. Now, we will clarify our docker-compose file to grasp the magic behind this.



Docker-compose file rationalization

On this docker-compose file, we use model 3.9 and we expose three providers, two volumes, and one default exterior community.



nextcloud_db service

Nextcloud help a number of DBMS: MySQL, MariaDB, Oracle, PostgresSQL. It’s as much as you to decide on your favourite DBMS. We select to make use of Postgres as it’s a very highly effective answer.



redis service

Redis is a wonderful trendy reminiscence cache answer to make use of for distributed caching. It’s utilized by Nextcloud to considerably enhance the Nextcloud server efficiency with reminiscence caching the place frequently-requested objects are saved for quicker retrieval.



nextcloud_web service

It’s the official Nextcloud container with all of the options provided.



cron service

Cron is a straightforward time-based job scheduler that runs small duties by itself with out the intervention of the consumer or the administrator. Cron can also be an necessary half for Nextcloud to be operating effectively.



Wrap up

On this tutorial, we clarify to you the best way to deploy your Nextcloud occasion in your Linux server with docker-compose and safe it with a free SSL certificates issued by Let’s Encrypt. One other factor you are able to do now could be to deploy a keycloak SSO answer subsequent to this to centralize authentication amongst all of your software. It’s fairly straightforward at this step and doesn’t have an effect on the earlier set up. In case you have any questions, go away a remark.

For those who like this tutorial, you’ll be able to buy me coffee. Within the upcoming tutorial, we’ll extra discover Nextcloud.

Add a Comment

Your email address will not be published. Required fields are marked *