pleskVPS

How to deploy Rocket.Chat in Plesk with docker

In this Howto I will show you how to deploy Rocket.Chat within plesk with docker

If you want to know more about Rocket.Chat, follow this link.

Prepare vHost:

First of all, we have to create a vHost in plesk, I will use chat.mastodontech.de in this example, you have to use your own domain or subdomain.

 

 

and secure it with LetsEncrypt:

 

 

Within the subdomain we use the file manager:

 

 

and remove all files and directories:

 

 

Now we config the Apache & nginx Settings for the domain.

Disable the Proxy Mode and Apply the settings.

After you applied the settings add the following block in Additional nginx directives (adjust your domain):

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_prefer_server_ciphers on;
ssl_session_timeout 180m;

location ~ ^/.* {
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header Host             $host;
    proxy_set_header X-Real-IP        $remote_addr;
    proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Forward-Proto http;
    proxy_set_header X-Nginx-Proxy true;
    proxy_http_version 1.1;

    proxy_redirect off;
}

And save with OK

Prepare Rocket.Chat:

For this step, we have to connect to our server with ssh.

If you do not have installed docker-compose yet, install it now:

curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose

and make it executable:

chmod +x /usr/local/bin/docker-compose

Next you have to edit your hosts-file:

nano /etc/hosts

and add your domain below the line with localhost:

127.0.0.1 localhost.localdomain localhost
127.0.0.1 chat.mastodontech.de chat

and save.

Then change the directory to your vHost (adjust your domain/subdomain):

cd /var/www/vhosts/mastodontech.de/chat.mastodontech.de

and create the following directories:

mkdir -p /var/www/vhosts/mastodontech.de/chat.mastodontech.de/data/runtime/db
mkdir -p /var/www/vhosts/mastodontech.de/chat.mastodontech.de/data/dump

now create a docker-compose.yml file:

nano docker-compose.yml

and add the following content:

version: '2'

services:
  rocketchat:
    image: rocketchat/rocket.chat:latest
    command: >
      bash -c
        "for i in `seq 1 30`; do
          node main.js &&
          s=$$? && break || s=$$?;
          echo \"Tried $$i times. Waiting 5 secs...\";
          sleep 5;
        done; (exit $$s)"
    restart: always
    volumes:
      - ./uploads:/app/uploads
    environment:
      - PORT=3000
      - ROOT_URL=http://chat.mastodontech.de # adjust your domain here
      - MONGO_URL=mongodb://mongo:27017/rocketchat
      - MONGO_OPLOG_URL=mongodb://mongo:27017/local
      - Accounts_UseDNSDomainCheck=false
    depends_on:
      - mongo
    ports:
      - 127.0.0.1:3000:3000

  mongo:
    image: mongo:4.0
    restart: always
    volumes:
     - ./data/db:/data/db
     - ./data/dump:/dump
    command: mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1
    labels:
      - "traefik.enable=false"

  # this container's job is just run the command to initialize the replica set.
  # it will run the command and remove himself (it will not stay running)
  mongo-init-replica:
    image: mongo:4.0
    command: >
      bash -c
        "for i in `seq 1 30`; do
          mongo mongo/rocketchat --eval \"
            rs.initiate({
              _id: 'rs0',
              members: [ { _id: 0, host: 'localhost:27017' } ]})\" &&
          s=$$? && break || s=$$?;
          echo \"Tried $$i times. Waiting 5 secs...\";
          sleep 5;
        done; (exit $$s)"
    depends_on:
      - mongo

save file and use docker-compose to bring up the container.

docker-compose up -d

We should correct the permissions of files and directories, the fastest way is to use plesk repair command:

plesk repair fs -v

then check if containers are running with:

docker ps

Round about a minute your containers up and running and the Setup-Wizard should appear in your webbrowser (you have to open it by yourself):

Add your admin-user here and finish the wizard.

The Documentation for Rocket.Chat is here.

To integrate your Nextcloud, look here

Have Fun and Happy Nextclouding with Rocket.Chat. 🙂

27 Gedanken zu „How to deploy Rocket.Chat in Plesk with docker

  1. Moin Markus
    Erstmal, Eine sehr gute Anleitung, da wünscht man sich mehr von.
    Leider hat es bei mir nicht so ganz funktioniert.

    Es scheint das der Docker-Container läuft, zumindest bekomme ich hier Up-Zeiten angezeigt.
    Leider bekomme ich aber beim Aufruf der Seite „403 Forbidden / NGINX“.
    In den Logs:
    *28296598 upstream sent no valid HTTP/1.0 header while reading response header from upstream
    *28296598 readv() failed (104: Connection reset by peer) while reading upstream
    *28296599 upstream sent no valid HTTP/1.0 header while reading response header from upstream
    *28296599 readv() failed (104: Connection reset by peer) while reading upstream
    *28296602 upstream sent no valid HTTP/1.0 header while reading response header from upstream
    *28296602 readv() failed (104: Connection reset by peer) while reading upstream.

    Was habe ich falsch gemacht?

    1. Hi. Up-Zeiten heißt noch nicht, dass der Container richtig läuft. Er braucht schon eine Weile bis er oben ist. Schau mal in die Logs vom Container. Wenn Du das nicht auf der CLI kannst, schaust Du in der Plesk-GUI
      Gruß Markus

  2. Hello again. I have a problem installing any app! The workspace is registered to rocket chat cloud and syncs without errors but when i try to install any app i get a blank red notification without any specific error in it. Searching the error logs in home folder i see this:

    2020/04/17 12:12:34 [error] 16637#0: *82647 „/var/www/vhosts/mydomain/httpdocs/api/apps/index.html“ is not found (2: No such file or directory), client: xx.xx.xx.xx, server: mydomain, request: „POST /api/apps/ HTTP/2.0“, host: „mydomain“, referrer: „https://mydomain/admin/marketplace“

    I tried reinstalling but nothing… Any ideas plz?

          1. Php-handler was set right but…. I did not set on the docker proxy rules to target the container (websites and domains->domain->docker proxy rules on Plesk panel). Without this everything was working fine and didn’t think it was needed. I did it a few minutes ago and now applications are installing fine. I repeated this on my first instance too and the problem was solved there too.

  3. Hallo,

    Ich habe die Anleitung so jetzt gemacht, nur kann ich nicht auf die Anmeldeseite von Rocketchat zugreifen.
    Nach dem Befehl „docker ps“ sollte ich doch mit nem Browser auf die Seite von meinem Rocketchat kommen oder ?
    Wer kann mir helfen ?

      1. Hallo,
        Ich bin jetzt soweit, das ich von RocketChat ne 403 Forbidden Seite bekomme.
        in der zweiten Zeile steht noch nginx.

        Welche Einstellung stimmt jetzt noch nicht?

        1. Hi,
          try to use this block in nginx:

          location ~ ^/.* {
              proxy_pass http://127.0.0.1:3000;
              proxy_set_header Host             $host;
              proxy_set_header X-Real-IP        $remote_addr;
              proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
          
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
              proxy_set_header X-Forward-Proto http;
              proxy_set_header X-Nginx-Proxy true;
              proxy_http_version 1.1;
          
              proxy_redirect off;
          }

          and give Feedback please 🙂

          1. Ok. It works after reinstalling in a new subtomain. I was using the main domain and it mod security was enabled on it. Disabling mod security did not helped but i aslo have tried a lot of possible solutions, even from terminal without any success and i thought maybe i should reinstall in a subdomain. It works great with a subdomain… I am not sure what went wrong in the main domain. Thank you again

  4. Have this error
    ERROR: yaml.scanner.ScannerError: while scanning a quoted scalar
    in „./docker-compose.yml“, line 33, column 14
    found unexpected end of stream
    in „./docker-compose.yml“, line 36, column 1

  5. hello Markus

    is there a way to deploy it with docker, without installing or modifying anything on linux?
    just on Plesk?
    Thanks in advanced

Schreibe einen Kommentar zu Markus Weingärtner Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht.