How to enable or connect SSL from host to Docker Mautic container

Your software
My Mautic version is: Mautic 3.3.3 (in a Docker container running on DigitalOcean host w/Apache2)
My PHP version is: PHP 7.3.27
My Database type and version is: MySQL5.7

Your problem
My problem is:
I can access Mautic OK at http://serverIP:8080 but I would like it to work also for https.

I suppose the issue I’m having requires some Docker expertise, so I’m hoping there are Docker experts or at least those who have worked with Docker Mautic in this community. There is a similar question on the Docker Mautic Github, but unfortunately, no inputs.

All I’m trying to do is enable SSL for my Mautic instance that is running in a Docker container. I was able to get LetsEncrypt certificate installed successfully on the host, but I’m still having issues trying to enable or connect it for the Mautic container. I read many different posts but most are using Ngnix and basically I’m going from one rabbit hole to another. Seems like this should be straightforward, but I’m missing something.

These errors are showing in the log:
Just can’t access Mautic using https.

Steps I have tried to fix the problem:
Created the SSL certificates.

These files were created:
/etc/letsencrypt/live/domain_name/fullchain.pem
/etc/letsencrypt/live/domain_name/privatekey.pem
/etc/apache2/sites-available/mydomain-le-ssl.conf

I ran netstat -tulpen on the host and it shows port 80 and 443 listening.

In my docker-compose.yml file, I’ve added the binding of port 8443:443 to the Mautic container. I’ve also tried to mount the volumes, and perhaps this is where I’m not doing it right.

ports:
      - 8080:80
      - 8443:443
  volumes:
      - mautic_data:/var/www/html
      - /etc/letsencrypt/live/mydomain.com:/etc/ssl/certs

Am I going in the right direction at all?

Is the mapping of port 443 ok?

For the volumes, should I mount the certificates to the /etc/ssl/certs directory inside the container? And am I mounting it correctly in the docker-compose file? Is mounting enough or do I need to somehow copy the SSL certificates from the host into the container?

Is there anything else I need to do? What am I missing?

Hey, if anyone runs into this issue, I posted this solution in Github.

The basic idea is to install certbot on the hosting server and create a new docker image based on the original mautic one.

In this new image you’ll reference the files created by certbot to enable ssl.

In the GitHub issue referenced at the beginning of this post you’ll find the Dockerfile, Makefile and every other detail needed to sort this out.