I’ve recently been looking into setting up a private chat server. I initially considered using IRC. While I enjoy the simplicity of launching a client from my shell to connect to an IRC server, other users might find the whole experience a little lack-luster or may not be as comfortable at the command-line. Also, I’m trying to promote participation in the chat room, so I wanted to minimize the barrier to entry.

So, I started looking for alternative chat platforms with a web interface. After a bit of searching, I came across Let’s Chat.

From the Let’s Chat homepage:

Let’s Chat is a persistent messaging application that runs on Node.js and MongoDB. It’s designed to be easily deployable and fits well with small, intimate teams.

It’s got a slick interface, handles file-uploads, authentication, and inline image viewing. It also doesn’t require me to set up any back-end chatting servers or databases.

While trying to test out Let’s Chat on my Ubuntu 14.04 LTS VM, I found the initial installation instructions a little too simplified. So here are the steps to get up-and-running with Let’s Chat.

Step 1: Install Node.js, NPM, MongoDB, and Git

$ sudo apt-get install nodejs \
                       npm \
                       nodejs-legacy \
                       mongodb \
                       mongodb-server \
                       git

Curious about the nodejs-legacy package? In order to resolve some namespace collision issues with a pre-existing package, Debian maintainers decided to rename the Node.js binary from its canonical name node to nodejs. This can cause some problems with Node.js projects, including Let’s Chat. Recognizing this problem, maintainers added the nodejs-legacy package that, when installed, creates a symlink from node to nodejs, resolving the issue.

Step 2: Download Let’s Chat Source

Clone the Let’s Chat repository:

$ cd ~
$ git clone https://github.com/sdelements/lets-chat.git

Move to the repo:

$ cd lets-chat

Install required Node.js packages:

$ npm install

Step 3: Configure Let’s Chat

Make a copy of the default settings file:

$ cp settings.yml.sample settings.yml

Step 3.1 (Optional): Enable uploads of .zip, .tgz, and other file types

Open your settings file (settings.yml):

$ vim settings.yml

Add the allowedTypes property to files, containing the content-types (aka MIME) of the file types you wish to allow to be uploaded:

files:
  enable: true
  provider: local
  local:
    dir: uploads
  allowedTypes:
    - 'image/jpeg'
    - 'image/png'
    - 'image/gif'
    - 'application/x-gzip'
    - 'application/x-tar'
    - 'application/x-zip'

Step 3.2 (Optional): Enable HTTPS

Open your settings file (settings.yml):

$ vim settings.yml

Set the https.enable property to true, and enter the path to your private key and certificate:

https:
  enable: true
  port: 5001
  key: server.key
  cert: server.crt

If you do not have a private key and certificate, you can follow the steps below to create a self-signed certificate.

Creating a self-signed certificate

Note: Self-signed certificates are useful in testing or internal setups, but shouldn’t really be used for production as they undermine security and will drive your users away. The browser will complain about the certificate whenever the page is accessed until the user explicitly makes an exception.

Generate a private key:

$ openssl genrsa -des3 -out server.key 1024

Generate a certificate signing request:

$ openssl req -new -key server.key -out server.csr

Generate the signed certificate:

$ openssl x509 -req -days 365 -in server.csr \
                              -signkey server.key \
                              -out server.crt

Step 4: Start the Server

Start the server:

$ npm start

Launch a browser and go to http://localhost:5000, or if you enabled HTTPS, https://localhost:5001.

Beyond this guide

If you plan to use Let’s Chat in a production environment, you likely want to set up a reverse-proxy using Nginx.