# Nginx Config For Mattermost with SSL Certification Generated By CertBot

**URL:** <https://forum.hhf.technology/t/nginx-config-for-mattermost-with-ssl-certification-generated-by-certbot/306>\
**Category:** General\
**Created:** [October 27, 2024, 5:48pm UTC](https://forum.hhf.technology/t/nginx-config-for-mattermost-with-ssl-certification-generated-by-certbot/306 "2024-10-27T17:48:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hhf.technoloy](https://forum.hhf.technology/user_avatar/forum.hhf.technology/hhf.technoloy/32/68_2.png) [@hhf.technoloy](https://forum.hhf.technology/u/hhf.technoloy)\
**Post date:** [October 27, 2024, 5:48pm UTC](https://forum.hhf.technology/t/nginx-config-for-mattermost-with-ssl-certification-generated-by-certbot/306/1 "2024-10-27T17:48:42Z")

</div>

## Step-by-Step Guide to Configure NGINX with Mattermost and Certbot

This guide outlines the steps to configure NGINX as a reverse proxy for Mattermost, including SSL setup using Certbot. Follow these instructions carefully to ensure a secure and efficient configuration.

### Step 1: Check Installed Versions

1. **Check NGINX Version:**

2. **Check Mattermost Version:**

3. **Check Certbot Installation:**

### Step 2: Configure NGINX for Mattermost

1. **Open NGINX Configuration File:**  
Edit the configuration file located at `/etc/nginx/sites-enabled/mm.yourdomain.com`.

2. **Define Upstream Server Block:**  
Add the following upstream block to define the Mattermost backend:

3. **Set Proxy Cache Path:**  
Define the cache path for NGINX:

4. **Configure HTTP to HTTPS Redirection:**  
Add the following server block to redirect HTTP traffic to HTTPS:

5. **Configure HTTPS Server Block:**  
Add the HTTPS configuration:

### Step 3: Test and Reload NGINX Configuration

1. **Test NGINX Configuration for Errors:**

2. **Reload NGINX to Apply Changes:**

### Step 4: Setting Up SSL with Certbot

1. **Install Certbot (if not already installed):**

2. **Obtain SSL Certificate Using Certbot:**  
Run the following command to automatically obtain and configure your SSL certificate:

3. **Verify Automatic Renewal of Certificates:**  
Certbot sets up a cron job for automatic renewal, but you can manually test it with:

### Conclusion

By following these steps, you have successfully configured NGINX as a reverse proxy for Mattermost with SSL encryption using Certbot, ensuring secure communication between your server and clients. Always remember to keep your software up to date for optimal security and performance.
