Hey,
since youāre using the docker version, this is going to be a bit of work, but basically, all youād have to do is spin up an additional container and configure it properly and make sure the containers do not interfere with each other.
So if youāre currently running docker-compose -f docker-compose.yml -f docker-compose.without-nginx.yml up -d
, you will just have to change this command a bit, but letās start from the beginning.
If you encounter error messages or problems at one step, let me know before continuing.
For the sake of simplicity, we will assume that the current docker setup you have is the main
setup, so this one will contain of three containers:
- Mattermost application (container-name
mattermost
)
- PostgreSQL database (container-name
postgres_mattermost
)
- nginx reverse proxy (container-name
nginx_mattermost
)
Additional domains will just consist of a postgresql
and a mattermost
containers with separate names.
Disclaimer: I havenāt tested all that, just writing it out of my head, so thereās a chance for fuzziness.
-
Stop your current environment
docker-compose -f docker-compose.yml -f docker-compose.without-nginx.yml down
-
Make sure your system is reachable from the internet on port 80 and admin.domain.mx
points to the public IP of your server so we can create the SSL certificates
-
In your .env
file, you will see two configuration options for CERT_PATH
and KEY_PATH
. We will only need one of them for the multihost setup, so open the file and modify this part of it to look like this:
#CERT_PATH=./volumes/web/cert/cert.pem
#KEY_PATH=./volumes/web/cert/key-no-password.pem
#GITLAB_PKI_CHAIN_PATH=<path_to_your_gitlab_pki>/pki_chain.pem
CERT_PATH=./certs/etc/letsencrypt/
#KEY_PATH=./certs/etc/letsencrypt/live/${DOMAIN}/privkey.pem
- Open your
docker-compose.nginx.yml
file and modify the `volumes:Ā“ section to look like this:
volumes:
- ${NGINX_CONFIG_PATH}:/etc/nginx/conf.d:ro
- ${NGINX_DHPARAMS_FILE}:/dhparams4096.pem
- ${CERT_PATH}:/certs:ro
- shared-webroot:/usr/share/nginx/html
- Remove the file
nginx/conf.d/default.conf
and place the following files in this directory instead:
httpredirect.conf Ā· GitHub
domain.conf.template Ā· GitHub
Verify that the directory looks like this then:
# ls nginx/conf.d -1
domain.conf.template
httpredirect.conf
Once thatās done, your preparation works are completed and the following steps need to be repeated for every domain you want to host (nginx-wise).
# the name of this application, only letters and numbers, please. The first one will be `mattermost`, this will be your main instance
export APPNAME=mattermost
export DOMAIN=admin.domain.mx
# generate a free Let's Encrypt certificate for this domain
# you will be asked some questions for e-mail addresses and stuff the first time you run it.
# if successful, you should see a respective message at the end telling you that the certificate files
# have been created properly
chmod 755 scripts/issue-certificate.sh
scripts/issue-certificate.sh -d $DOMAIN -o ${PWD}/certs`
# clone the template to a working configuration, replacing the values
sed -e 's/__APPNAME__/'$APPNAME'/g' -e 's/__DOMAIN__/'$DOMAIN'/g' nginx/conf.d/domain.conf.template > nginx/conf.d/$APPNAME.conf
This should, in theory, be all thatās necessary.
You can now try to start the environment using the following command:
docker-compose -f docker-compose.yml -f docker-compose.nginx.yml up -d
If you encountered errors at some point, please provide the console log (command you typed, message you received) so I can look at it.
Once the first instance is running, weāll go ahead and create a second one.