Skip to content

Install Mattermost with Nginx and Let's Encrypt on Windows VPS

Cloud Infrastructure Expert
Install Mattermost with Nginx and Let's Encrypt on Windows VPS

 

 

Introduction

This guide walks you through the installation of Mattermost on a Windows VPS using Nginx as a reverse proxy and securing it with a free SSL certificate from Let’s Encrypt.

Prerequisites

  • A Windows VPS with administrative access.
  • A registered domain name pointed to your VPS IP address.
  • The Windows VPSSubsystem for Linux (WSL) installed, or use a Linux virtual machine. Follow Microsoft’s guide here.
  • Basic knowledge of command-line operations.

Step 1: Install Required Software in WSL

Open your WSL terminal and run the following commands:

sudo apt update
sudo apt install curl wget gnupg2 software-properties-common

Step 2: Install Mattermost

You can install Mattermost using Docker for a simple setup. First, install Docker if you haven’t done so:

sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker

Now, create a directory for Mattermost:

mkdir ~/mattermost
cd ~/mattermost

Next, create a docker-compose.yml file:

nano docker-compose.yml

And add the following content:

version: '3'

services:
  mattermost:
    image: mattermost/mattermost-team-edition:latest
    restart: unless-stopped
    ports:
      - "8065:8065"
    volumes:
      - mattermost_data:/mattermost/data

volumes:
  mattermost_data:

Now, run Mattermost with Docker:

sudo docker-compose up -d

Step 3: Install Nginx

To install Nginx, run the following command:

sudo apt install nginx

Start Nginx and enable it to run at boot:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 4: Configure Nginx as a Reverse Proxy

Create a new Nginx configuration file for Mattermost:

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

Add the following configuration, replacing your_domain.com with your actual domain:

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;
    }
}

Link the configuration file to the `sites-enabled` directory:

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

Test the Nginx configuration for syntax errors:

sudo nginx -t

If there are no errors, restart Nginx:

sudo systemctl restart nginx

Step 5: Install Certbot for Let’s Encrypt SSL

To install Certbot, run the following commands:

sudo apt install certbot python3-certbot-nginx

Step 6: Obtain a Free SSL Certificate

Run the following command to obtain a SSL certificate:

sudo certbot --nginx -d your_domain.com

Follow the prompts during the certificate issuance process. If successful, Certbot will automatically configure Nginx to use SSL.

Step 7: Set Up Automatic Renewal of SSL Certificates

Certbot sets up a cron job by default for automatic renewal, but you can test it using:

sudo certbot renew --dry-run

Step 8: Access Mattermost

Now you should be able to access your Mattermost instance by visiting https://your_domain.com in your web browser.

Conclusion

You have successfully installed Mattermost on a Windows VPS using WSL, configured Nginx as a reverse proxy, and secured it with Let’s Encrypt SSL.

Resources

Explore more

More on this topic

Netcloud24
Netcloud24
Cloud Infrastructure Expert · NetCloud24

Comments are closed.