- Notifications
You must be signed in to change notification settings - Fork4
jzombie/docker-mqtt-mosquitto-cloudflare-tunnel
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Note: For examples of customization, another branch is available, which:
- Restricts wildcard searches across users (in a naive fashion where the first level of a topic is the username, with protections provided by anACL file)
- Encrypts retained messages usinggocryptfs
- Auto-saves retained messages after every message
You can find it here:protected-no-wildcard branch or view thediff instead.
This setup demonstrates how to configure and deploy an MQTT broker using Eclipse Mosquitto within a Docker container and securely expose it to the internet via a Cloudflare Tunnel. This setup is particularly useful for IoT applications, allowing secure and scalable message brokering over the MQTT protocol.
- https://en.wikipedia.org/wiki/MQTT
- https://mosquitto.org/
- https://www.cloudflare.com/
- https://www.cloudflare.com/products/tunnel/
The following steps will guide you through the process of setting up an MQTT broker, configuring a Cloudflare Tunnel to expose the broker to the public internet, and managing access and routing through Cloudflare's network.
Go to the Cloudflare Dashboard and log in with your credentials.
In the left sidebar, click on"Zero Trust".
Under the"Networks" section in the sidebar, select"Tunnels".
Click on"Create a tunnel".
On the next screen, select"Cloudflared" as the tunnel type and click"Next".
Enter a name for your tunnel, such as
my_tunnel_name
, and click"Save tunnel".Choose"Docker" as your environment. Copy the provided Docker command which includes your unique token.
Create an.env
file in the base directory of this repo, and addCLOUDFLARE_TUNNEL_TOKEN=your_token
. See.env.sample for example.
Note: You do not need to run the provided Docker command on the screen. This repository replaces that step.
After running the connector, navigate to the"Tunnels" section again and select the newly created tunnel.
Click on"Next" to proceed to the hostname configuration.
On the"Public Hostname Page", fill in the required details:
- Public hostname: Choose your desired subdomain and domain.
- Service: Select the service type (HTTP).
- URL: Set the URL to point to your Mosquitto service (e.g.,
mosquitto:9001
). Docker will route themosquitto
hostname to the relevantcontainer_name
in thedocker-compose.yml
.
Click"Save hostname" to finalize the configuration.
docker compose up
About
MQTT Broker via Cloudflare Tunnels, using Docker.
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.