How to Install Mattermost with Nginx Proxy and Free Let's Encrypt SSL on Ubuntu 24.04

 

 

Introduction

Mattermost is an open-source platform for team communication. This guide will walk you through installing Mattermost with Nginx as a reverse proxy and securing it with a free SSL certificate from Let's Encrypt on Ubuntu 24.04.

Prerequisites

  • A server running Ubuntu 24.04
  • Root access or a user with sudo privileges
  • Domain name pointing to your server's IP address

Step 1: Update the System

Start by updating your package list and upgrading your installed packages:

sudo apt update
sudo apt upgrade -y

Step 2: Install Required Dependencies

Install dependencies required for Mattermost and Nginx:

sudo apt install -y nginx postgresql postgresql-contrib

Step 3: Install Mattermost

Download the latest Mattermost server from the official website:

wget https://releases.mattermost.com/$(wget -qO- https://api.github.com/repos/mattermost/mattermost-server/releases/latest | grep tag_name | cut -d '"' -f 2)/mattermost-server-*.tar.gz

Extract Mattermost:

tar -xvzf mattermost-server-*.tar.gz

Move the Mattermost folder to the appropriate location:

sudo mv mattermost /opt/

Step 4: Configure PostgreSQL Database

Log into PostgreSQL and create a new database and user for Mattermost:

sudo -u postgres psql

Run the following commands in the PostgreSQL shell:

CREATE DATABASE mattermost_db;
CREATE USER mattermost_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE mattermost_db TO mattermost_user;
\q

Step 5: Configure Mattermost

Edit the Mattermost configuration file:

sudo nano /opt/mattermost/config/config.json

Update the following settings:

"DriverName": "postgres",
"DataSource": "mattermost_user:your_password@tcp(localhost:5432)/mattermost_db?sslmode=disable",

Also set the SiteURL to your domain:

"SiteURL": "https://your_domain.com",

Step 6: Start Mattermost

Start the Mattermost server:

cd /opt/mattermost/bin
sudo ./mattermost 

To run Mattermost in the background, you can use screen or set it up with a service file.

Step 7: Install Nginx

Start Nginx and enable it to run on boot:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 8: Configure Nginx as a Reverse Proxy

Create a new Nginx configuration file for Mattermost:

sudo nano /etc/nginx/sites-available/mattermost

Enter the following configuration:

server {
    listen 80;
    server_name your_domain.com;

    location / {
        proxy_pass http://localhost:8065;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Enable the configuration:

sudo ln -s /etc/nginx/sites-available/mattermost /etc/nginx/sites-enabled/

Test the Nginx configuration:

sudo nginx -t

Restart Nginx:

sudo systemctl restart nginx

Step 9: Install Certbot for Let's Encrypt SSL

Install Certbot:

sudo apt install certbot python3-certbot-nginx

Step 10: Obtain a Free SSL Certificate

Run Certbot to get your SSL certificate:

sudo certbot --nginx -d your_domain.com

Follow the instructions to complete the SSL setup. Certbot will automatically configure Nginx to use the new certificate.

Step 11: Test HTTPS Access

Open your browser and navigate to https://your_domain.com to verify that Mattermost is accessible over HTTPS.

Conclusion

You have successfully installed Mattermost with Nginx as a reverse proxy and secured it with a Let's Encrypt SSL certificate on Ubuntu 24.04.

Resources

  • 0 brukere syntes dette svaret var til hjelp
Var dette svaret til hjelp?

Relaterte artikler

Boost Your Ubuntu System's Performance with a Swap File: A Step-by-Step Guide

What is a Swap File? A swap file in Ubuntu serves as dedicated virtual memory on your hard...

How to Migrate ISPConfig 2, ISPConfig 3.x, Confixx, CPanel or Plesk to ISPConfig 3.2 (single server)

Introduction Migration from other control panels like ISPConfig 2, ISPConfig 3.x, Confixx,...

How to Install and Configure Zabbix Server and Client on Rocky Linux 9

Introduction Zabbix is an open-source monitoring solution that provides real-time...

How to Install CockroachDB Cluster on Debian 12

Introduction CockroachDB is a distributed SQL database built to handle large-scale,...

How to Install Joomla with Apache and Let's Encrypt SSL on AlmaLinux 9

Introduction Joomla is a popular open-source content management system (CMS) used to build...