How to deploy Rocket.Chat on AWS – Part II

Rocket.Chat on Debian 9


This is the second part of the tutorial on how to deploy Rocket.Chat on AWS (Amazon Web Services). In part one we saw how to configure an instance, get a SSL certificate and configure Route 53. Now, it’s time to set up NGINX, Docker and finally Rocket.Chat.

Install and configure NGINX

On the EC2 instance, install NGINX, which is available in the Ubuntu repositories:

# apt install nginx

Then configure it. To do this, first make a backup of the default configuration files:

# cd /etc/nginx/sites-available
# mv default default.backup

Next, create a new one:

# $EDITOR /etc/nginx/sites-available/default

In that, paste the following content:

server {
   listen 443 ssl;
   ssl_certificate /etc/letsencrypt/live/;
   ssl_certificate_key /etc/letsencrypt/live/;
   ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
   ssl_prefer_server_ciphers on;
   root /usr/share/nginx/html;
   index index.html index.htm;
   # Make site accessible from http://localhost/
   server_name localhost;
   location / {
     proxy_pass http://localhost:3000/;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection "upgrade";
     proxy_set_header Host $http_host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forward-Proto http;
     proxy_set_header X-Nginx-Proxy true;
     proxy_redirect off;
 server {
   listen 80;
   return 301 https://$host$request_uri;

This removes the listening on port 80, and the traffic is redirected on port 443, with SSL offering a secure connection. Lines 4 and 5 are the paths to the certificate and certificate key generated in the previous part of this tutorial.

In the  location section,  NGINX is configured as reverse proxy to forward to port 3000, which is the one used by Rocket.Chat.

Save, exit and stop NGINX:

# service nginx stop

Test NGINX with:

# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 
nginx: configuration file /etc/nginx/nginx.conf test is successful

Now it’s time to start the web server:

# service nginx start

Go with a web browser to A page displaying a 502 Bad Gateway will appear, this is ok! The important part is to check in the address bar if there is a lock, which means that the connection is correctly secured by Let’s Encrypt Authority X1. The certificate will expire in 90 days, so remember to renew it.

Install Docker

On the instance, install Docker and its dependencies by executing the following command:

# sudo wget -qO- | sh

Next, to use Docker as the non-root user, add the ubuntu user to the docker group:

# usermod -aG docker ubuntu

Next, install Docker Compose:

# curl -L > /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose

Set up containers

First of all, create the following directories:

# mkdir -p /var/www/
# mkdir -p /var/www/

Next, create a new compose configuration file:

# $EDITOR /var/www/

In that file, paste the following content:

  image: mongo:3.0
    - ./data/runtime/db:/data/db
    - ./data/dump:/dump
  command: mongod --smallfiles

  image: rocketchat/
    - MONGO_URL=mongodb://db:27017/rocketchat
    - ROOT_URL=
    - db:db
    - 3000:3000

Configure Upstart

Let’s use Upstart to manage MongoDB and Rocket.Chat start and restart services. Create a new file for MongoDB:

# $EDITOR /etc/init/rocket_chat_mongo.conf

In it, paste:

description "MongoDB service for Rocket.Chat"

# Start MongoDB after docker is running
start on (started docker)
stop on runlevel [!2345]

# Automatically Respawn with finite limits
respawn limit 99 5

# Path to our app
chdir /var/www/

   # Showtime
   exec /usr/local/bin/docker-compose up db
end script

Save, exit, and make the same for Rocket.Chat:

# $EDITOR /etc/init/rocket_chat.conf

Pasting there:

description "Rocket.Chat service manager"

# Start Rocket.Chat only after mongo job is running
start on (started rocketchat_mongo)
stop on runlevel [!2345]

# Automatically Respawn with finite limits
respawn limit 99 5

# Path to our app
chdir /var/www/

   # Bring up Rocket.Chat app
   exec /usr/local/bin/docker-compose up rocketchat
end script

Save and exit.


Restart the server; after the new logging in. Docker should download and set up images. After a few minutes, these can be seen with the following command:

# docker ps -a

Or, looking at the Upstart jobs log files:

# cat /var/log/upstart/rocket_chat_mongo.log
# cat /var/log/upstart/rocket_chat.log

From here you can use any web browser to go to, create a new admin user and start using Rocket.Chat.


  1. Eаᴦn woᴦkiпɡ from hom℮ fr੦m tɯo‐sɩx h Ꮷaily¸ and stαrt geτtiᴨƍ pɑid fᴦօᴍ ᴏոe τ٥ τᏂree τhousaᴨd ԁංllars ℮aᴄh ԝeek See мօre info οπ ſօΙlowing рαge› V15.UK/WqoBO

  2. Ϲhecĸ ௦ʋᴛ α great ԝауѕ τ๐ geτ рaiԁ ɑ Ɩ౦ᴛ of ᴄash bʏ աorking bаsiᴄ work oᴠer vveb ſroᴍ ყour հ૦uѕe f๐r few shoгt Ꮒoսrѕ ᜵dai|у ~ Clıϲᴋ oп tհ℮ ǀᎥnk GET.LC/yGUZX


  3. I initiated freelancing over world wide web, through doing some basic tasks which primarily demanded a computer and consequently access to net and additionally Now I am satisfied than ever before… six months time get gone by since i started out this and therefore i received cash total of $36,000… Basically I make eighty usd each hour and even work for 3 to four hrs most of the days.And beauty of this is that you can organize time whenever you work and so for how long as you like but you still gain a paycheck weekly. —->>>LEARN A lot more About That here-> V15.UK/96i5Z


  4. I started out freelancing over internet, through doing some fundamental work which solely required your working personal computer and consequently usage of internet and Now I am delighted than always… 6 months have passed by when i started out this and additionally i had profit total of 36 thousand dollars… Basically I earn 80 bucks each and every hour as well as work for 3 to four hours most of the times.And beauty of this is that you can manage precious time when you work and so for how long as you like but you still get a take-home pay in one week. —->>>LEARN Additional Regarding It here-> RU.VU/bzJLB


  5. After following these instructions, Docker was installed, but it didn’t start the containers automatically on reboot. Did I miss something?


Please enter your comment!
Please enter your name here