Setup Reverse-Proxy with Docker + Traefik + Nginx + PHP + MySQL + Mosquitto + phpMyAdmin + Basic Authentication

This article serves to explain how to make a sub-domain point to a particular container in a simple and efficient way. I am writing it because I came across a lot of difficulties when I tried to do it.

For example, I used something like: (web), (phpMyAdmin), wss:// 1884 (mosquito), etc. My goal was to simplify and start using something like: (web), (phpMyAdmin), wss:// (mosquitto), etc.

That is, in addition to pointing a subdomain to a particular container, I also wanted to use the same port for different protocols.

That’s when I discovered Traefik. In addition to satisfying my needs in a very simple way, it also generates SSL certificates for all required domains/sub-domains.

For everything to work as expected, we only need the following files, just changing the email, domain and subdomains in the traefik.toml and docker-compose.yml files.







After creating these files, just run the command:

Now when you access the configured URL you will receive the message “Hello!”. You can also use the URL configured in the Traefik container to check the current status of your containers.

To try out Mosquitto, you only need to use a MQTT client (for example MQTT.js), subscribe to a topic and publish anything to that same topic, for example:

Basic Authentication

If you want to add an extra layer of security to your application, you just need to add the following to your traefik.toml file:


Passwords can be encoded in MD5, SHA1 and BCrypt: you can use htpasswd to generate them. (Eg


Full Stack Web Developer

Full Stack Web Developer