We're Hiring!

Mattermost, Inc.

Mattermost send email notification problems

That is great! So, the next few steps are going to have to be done in a specific order, otherwise, it won’t work.
Here is the first step:

  • You will need to contact your boss/manager who controls the DNS records for your domain and ask them to set up a new subdomain that points towards the IP address of your server. You can make the subdomain be called whatever you desire, just please let us know what it is when you do make that decision.

The next step, which I will describe the instructions on once we have determined the subdomain name, will be to setup the Apache configuration files and Mattermost configuration files, and generate a SSL certificate.

Dear @XxLilBoPeepsxX,
My boss would like to ask that what is subdomain. For example, if he use http://invisiblenotes.com:8341/ to be the subdomain, should he add string before or after the link? Thank you.

Update: My boss prefer to change the site URL to be http://mat.invisiblenotes.com:8341/ . Is it correct for creating subdomain?

Yes! However, it will just be https://mat.invisiblenotes.com because we are going to use HTTPS to allow you to access your Mattermost instance just by typing the URL mat.invisiblenotes.com into your browser. This will make it a lot easier for your users, as well as providing the additional security of SSL.
Does that work?

Dear @XxLilBoPeepsxX,
I would like to reply you that your suggestion does work. Thank you.

Dear @XxLilBoPeepsxX,
I would like to ask that do you receive my reply? Thank you.

Hello! My apologies, yes, I have received your reply, I’ve just been very busy this week and got caught up in work stuff. Here is what we will accomplish in the next step:

  • Creating the Apache reverse proxy and VHOST configuration
  • Configuring the Mattermost Configuration to become reverse proxied through Apache, and connect to the subdomain
  • Generating a SSL certificate with Certbot and LetsEncrypt, to protect your Mattermost instance with HTTPS

These three steps are pretty much the end of the setup for Mattermost specifically, although I would be more than happy to assist in the reconfiguration of the setup of the other domains if desired so that they are more reliable as well.

Let’s get started:


Creating the Apache VHOST Configuration

  • Open your command line, and change directory to the /etc/httpd/conf.d directory:
    cd /etc/httpd/conf.d/
  • Create the configuration file:
    sudo touch mat.invisiblenotes.com.conf
  • Open the configuration file in your command-line text editor:
    sudo nano mat.invisiblenotes.com.conf
  • Copy the following code and paste it into the file by right-clicking your mouse on the command prompt window, if working over SSH, or by pasting the text into the file if you copied the code from a browser on the server itself. This is our VHOST HTTP Configuration:

<VirtualHost *:80>
  #ServerName directive specifies the URL that the configuration listens for. 
  ServerName mat.invisiblenotes.com
  #ServerAdmin specifies the email to be displayed on all error pages shown to users as 
  #the support email for the domain.
  ServerAdmin hostmaster@mydomain.com
  #Reverse proxy configuration for Mattermost WebSockets and HTTP/HTTPS requests. 
  ProxyPreserveHost On

  # Set web sockets
  RewriteEngine On
  RewriteCond %{REQUEST_URI} /api/v[0-9]+/(users/)?websocket [NC,OR]
  RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC,OR]
  RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
  RewriteRule .* ws://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L]

  <Location />
        Require all granted
        ProxyPass http://127.0.0.1:8065/
        ProxyPassReverse http://127.0.0.1:8065/
        ProxyPassReverseCookieDomain 127.0.0.1 mat.invisiblenotes.com
  </Location>
</VirtualHost>
Note: You should change the email address located in the line "ServerAdmin hostmaster@mydomain.com" to a suitable support contact email, this email will be shown on all error pages that users potentially encounter. To disable this, simply change the line to "#ServerAdmin hostmaster@mydomain.com" minus the quotes.

  • To exit and save from the nano command-line editor, to exit from the editor, use CTRL+X, then select y when prompted if you want to save the file, and then hit enter(return) to save. At this point, you should be back to your command prompt now.

  • Next we will check the configuration for errors, and verify that the file is correctly setup and functional. If you receive anything other than the expected output, please do not continue with the rest of the steps, and instead reply with the error you receive, so that we can get it figured out :slight_smile:
    Check your configuration files to make sure they are error-free by running the command:
    sudo apachectl configtest
    The expected output should be Syntax OK
    If you see anything other than Syntax OK or there is anything else that you see returned in addition to Syntax OK, please send the information here, as it is better to be safe and make sure there are no errors than to risk breaking the server.

If you have successfully verified that the configuration is functional, we can now apply it by running the command sudo systemctl reload httpd

At this point, we have now configured the reverse proxy for the domain, however, we need to reconfigure our Mattermost settings to reflect the same values as Apache.

We need to make sure that the Mattermost settings are configured to use the correct domain name and listen on the internal IP and port so that the reverse proxy functions properly.
Here is how we can do this:

Note that the following steps are assuming that you have installed Mattermost to the recommended location, `/opt/mattermost`. If you have installed it in a different location, replace `/opt/mattermost` with your own file path.
  1. cd /opt/mattermost/config/
  2. cp config.json config.json.bak (Create a backup of original configuration)
  3. nano config.json
    Now we need to change several values, and make sure they correspond to the Apache configuration.
  4. In the first section of the config.json file, here is what we want it to look like:
"ServiceSettings": {
        "SiteURL": "https://mat.invisiblenotes.com",
        "WebsocketURL": "",
        "LicenseFileLocation": "",
        "ListenAddress": ":8065",
        "ConnectionSecurity": "",
        "TLSCertFile": "",
        "TLSKeyFile": "",
        "TLSMinVer": "1.2",
        "TLSStrictTransport": false,
        "TLSStrictTransportMaxAge": 63072000,
        "TLSOverwriteCiphers": [],
        "UseLetsEncrypt": false,
        "LetsEncryptCertificateCacheFile": "./config/letsencrypt.cache",
        "Forward80To443": false,
        "TrustedProxyIPHeader": [
            "X-Forwarded-For",
            "X-Real-IP"
        ],

Once your configuration file reflects the same as above, save the file and exit the editor, and restart Mattermost with sudo systemctl restart mattermost
It may take a couple of seconds, but it should work. If you encounter any errors or it fails, please let us know, of course.

  • Finally, we need to generate the HTTPS SSL certificate. From the command line, run the command sudo certbot --apache and follow the prompts, providing information as requested to the program. When you are prompted to select a number for the domain, such as the following, select the number that is next to the domain. In the example provided, that would be 1.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: mat.invisiblenotes.com
2: example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):

Continue to provide information to the program, and make sure to ENABLE HTTPS redirect on successful generation of the certificate, this is one of the final questions CertBot will ask you.

If you encounter any errors with this step, please provide the full output, and error messages, so that we can get it figured out. If this goes without any issues, you can now navigate to https://mat.invisiblenotes.com and login to your Mattermost instance!
Please let me know if you have any questions, concerns, or if anything goes wrong! :slight_smile:

Dear @XxLilBoPeepsxX,
I would like to reply you that there are errors of the configuration. Thank you. Please refer to below image and mat.invisiblenotes.com.confconfiguration file.

  #ServerName directive specifies the URL that the configuration listens for. 
  ServerName mat.invisiblenotes.com
  #ServerAdmin specifies the email to be displayed on all error pages shown to users as 
  #the support email for the domain.
  ServerAdmin serhj25@hotmail.com
  #Reverse proxy configuration for Mattermost WebSockets and HTTP/HTTPS requests. 
  ProxyPreserveHost On

  # Set web sockets
  RewriteEngine On
  RewriteCond %{REQUEST_URI} /api/v[0-9]+/(users/)?websocket [NC,OR]
  RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC,OR]
  RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
  RewriteRule .* ws://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L]

  <Location />
        Require all granted
        ProxyPass http://127.0.0.1:8065/
        ProxyPassReverse http://127.0.0.1:8065/
        ProxyPassReverseCookieDomain 127.0.0.1 mat.invisiblenotes.com
  </Location>
</VirtualHost>

Ahh that is just a warning, your configuration is all good! This basically is saying that, in the httpd.conf file, there is not a configured ServerName parameter setup to tell the server what domain it is running, you can safely ignore this error, I have the same one on my setup, it will not affect the operation of the server at all, you are all good to continue with the steps provided in the last post I sent!

Dear @XxLilBoPeepsxX,
I would like to inform you that it has error about configuration. Please refer to below image. Thank you.

Did you have your boss add the IP of your server into a DNS record for the subdomain?

Dear @XxLilBoPeepsxX,
I did not have my boss add the IP of your server into a DNS record for the subdomain.

That is the problem, you need to have the public IP of your server (the one you are working on, to install the mattermost instance) added to a DNS record for the subdomain, otherwise it will not work, as the subdomain doesn’t exist yet.

1 Like

Dear @XxLilBoPeepsxX ,
I would like to ask that whether you can send the steps of creating the Apache VHOST Configuration for Ubuntu use, as my boss decide to use Ubuntu for testing it. The subdomain is also https://mat.invisiblenotes.com. Below is the image of my ubuntu system:

Yes, I certainly can!
I use Ubuntu 18.04 and Apache personally to run my Mattermost instance, so it is most definitely doable!

Here’s some background about what a VHOST is and what a properly configured VHOST allows you to do. I want to include this so that you hopefully understand how using VHOST setup for all of your websites on the server, and not just Mattermost, will greatly improve both user experience as well as making the management of the server itself much easier.

The basic unit that describes an individual site or domain is called a virtual host(VHOST). These designations allow the administrator to use one server to host multiple domains or sites off of a single interface or IP by using a matching mechanism.

By simply specifying the name of the website in a given configuration file, an Apache web server can host multiple websites, such as example.com, help.example.com, and so on, without any ports or other information needed after the end of the URL. This is called name-based virtual hosting. With name-based virtual hosting, the Apache server relies on the client (Web Browser) to report the hostname (website URL) as part of the HTTP headers when a user navigates to a given website. These HTTP headers are automatically sent with all website activity, and already exist - it’s simply a matter of using them. Based on the HTTP headers sent by a given website user, the server will respond with the matching website. Using this technique, many different hosts can share the same IP address, which means that you can run multiple websites from the same server and port, instead of appending extra identifiers such as example.com:81 to the URL.

Before you continue to the following steps, please make sure that you have installed Mattermost on your server following the Official Documentation to do so, as well as MySQL and Apache, which can both be installed using apt-get per the usual.

Once you have the above installed, it is now time to set up your Apache configuration file to use a reverse proxy for Mattermost. The steps to do this are pretty much the same as the steps I walked you through in prior messages on this. If you are confused about any of the steps or commands used in this process, please do not hesitate to ask for clarification, I am more than happy to do so.

Let’s get into it:

  1. Open a command prompt and connect over SSH to the web server, or if you have access in-person to the server, open a terminal.
  2. Change directories to the directory that contains the Apache virtual host configuration files:
    cd /etc/apache2/sites-available
  3. Create the file that will contain your Mattermost virtual host configuration:
    sudo touch 100-http-mat.invisiblenotes.conf
    Executing the list files ls command, you will now see there is a file with the name 100-http-mat.invisiblenotes.conf in the directory.
  4. Now, we are going to open the file and enter the virtual host configuration into the file:
    sudo nano 100-http-mat.invisiblenotes.conf
    This will open the nano command-line file editor in your console.
  5. I have pre-prepared a configuration file for you to use, all you need to do is copy and paste it into the configuration file we opened in the step above.
    Here is what to paste into the configuration file:
<VirtualHost *:80>
  #ServerName directive specifies the URL that the configuration listens for. This is the section that tells the user's web browser what website to return when someone has navigated to your domain. 
  ServerName mat.invisiblenotes.com
  #ServerAdmin specifies the email to be displayed on all error pages shown to users as 
  #the support email for the domain.
  ServerAdmin email@mydomain.com
  #Reverse proxy configuration for Mattermost WebSockets and HTTP/HTTPS requests. 
  ProxyPreserveHost On

  # Set web sockets
  RewriteEngine On
  RewriteCond %{REQUEST_URI} /api/v[0-9]+/(users/)?websocket [NC,OR]
  RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC,OR]
  RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
  RewriteRule .* ws://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L]

  <Location />
        Require all granted
        ProxyPass http://127.0.0.1:8065/
        ProxyPassReverse http://127.0.0.1:8065/
        ProxyPassReverseCookieDomain 127.0.0.1 mat.invisiblenotes.com
  </Location>
</VirtualHost>

  1. Now that we have entered the configuration into the configuration file, we are finished with the Apache configuration file. Hold down the Ctrl key while selecting the x key, and you will see a message pop up:

    Enter the Y key on your keyboard, and press enter (return key), and you should now be back at your command prompt!

Now that we have added our configuration file, we need to make sure that the needed Apache Modules have been installed and enabled, prior to bringing the website fully online. If you have not worked with Apache modules before, or are confused about the functions they serve, check out the resource linked above.
If you have not installed the modules, you should be able to install all of the modules all at once by running the command sudo apt-get install apache2-utils -y

  1. Let’s enable the Apache modules with the following command:
    sudo apachectl enmod mod_rewrite mod_proxy mod_proxy_http mod_proxy_wstunnel and then enable the virtual host configuration file we created with the following command:
    sudo a2ensite 100-http-mat.invisiblenotes.conf

  2. Once you do that, simply reload Apache to rescan the configuration files:
    sudo systemctl reload apache2 and then you should be able to navigate to http://mat.invisiblenotes.com/ and access your Mattermost install. If this works, I’d like to walk you through the HTTPS certificate, which is 99% automated, so that you can secure your Mattermost instance with the benefits of SSL encryption.

Please let me know if you encounter any issues or unknown responses, I’ll be here to help!

Dear @XxLilBoPeepsxX ,
I would like to inform you that sudo apachectl enmod mod_rewrite mod_proxy mod_proxy_http mod_proxy_wstunnel , it display below error. However, I can’t find any error in Apache Error log. Thank you.


Hmmm that’s quite interesting, if you use the command sudo cat /var/log/apache2/error.log, what are the most recent errors that are shown?

Dear @XxLilBoPeepsxX ,
I would like to reply you that there are no errors that are shown. Thank you. Please refer to below image:

1 Like

Interesting! I’m thinking that for now we can ignore that error then and continue the procedure, which we left off at here:

Dear @XxLilBoPeepsxX ,
I would like to reply you that there is error. Please refer to below image.


Also, if I run sudo cat /var/log/apache2/error.log. There is no error. Please refer to below image of file included cat /var/log/apache2. Is it related to problem? Thank you.

Ahh yes I see the issue, your Apache server is not started, and as a result, isn’t running. Here is how you can fix this:
sudo systemctl enable apache2
and then run the command sudo systemctl start apache2
Then, you should be able to see the status of the Apache webserver by running the command
sudo systemctl status apache2