{"id":20002228,"url":"https://github.com/jzombie/docker-mqtt-mosquitto-cloudflare-tunnel","last_synced_at":"2025-05-04T15:34:06.887Z","repository":{"id":250642995,"uuid":"834999355","full_name":"jzombie/docker-mqtt-mosquitto-cloudflare-tunnel","owner":"jzombie","description":"MQTT Broker via Cloudflare Tunnels, using Docker.","archived":false,"fork":false,"pushed_at":"2024-09-21T17:53:41.000Z","size":952,"stargazers_count":18,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T07:43:09.259Z","etag":null,"topics":["cloudflared","docker","docker-compose","mosquitto-mqtt-broker","mqtt-broker"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jzombie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-29T00:10:31.000Z","updated_at":"2025-03-11T15:59:37.000Z","dependencies_parsed_at":"2024-11-13T05:32:02.948Z","dependency_job_id":null,"html_url":"https://github.com/jzombie/docker-mqtt-mosquitto-cloudflare-tunnel","commit_stats":null,"previous_names":["jzombie/docker-mqtt-mosquitto-cloudflare-tunnel"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jzombie%2Fdocker-mqtt-mosquitto-cloudflare-tunnel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jzombie%2Fdocker-mqtt-mosquitto-cloudflare-tunnel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jzombie%2Fdocker-mqtt-mosquitto-cloudflare-tunnel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jzombie%2Fdocker-mqtt-mosquitto-cloudflare-tunnel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jzombie","download_url":"https://codeload.github.com/jzombie/docker-mqtt-mosquitto-cloudflare-tunnel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252356875,"owners_count":21735037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflared","docker","docker-compose","mosquitto-mqtt-broker","mqtt-broker"],"created_at":"2024-11-13T05:20:09.062Z","updated_at":"2025-05-04T15:34:06.451Z","avatar_url":"https://github.com/jzombie.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"![CI](https://github.com/jzombie/docker-mqtt-mosquitto-cloudflare-tunnel/actions/workflows/ci.yml/badge.svg)\n\n# Docker MQTT Mosquitto Cloudflare Tunnel\n\n**Note:** For examples of customization, another branch is available, which:\n\n- Restricts wildcard searches across users (in a naive fashion where the first level of a topic is the username, with protections provided by an [ACL file](https://github.com/jzombie/docker-mqtt-mosquitto-cloudflare-tunnel/blob/protected-no-wildcard/mosquitto/aclfile))\n- Encrypts retained messages using [gocryptfs](https://nuetzlich.net/gocryptfs/)\n- Auto-saves retained messages after every message\n\nYou can find it here: [protected-no-wildcard branch](https://github.com/jzombie/docker-mqtt-mosquitto-cloudflare-tunnel/tree/protected-no-wildcard) or view the [diff](https://github.com/jzombie/docker-mqtt-mosquitto-cloudflare-tunnel/compare/main...protected-no-wildcard) instead.\n\n---\n\nThis 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.\n\n- https://en.wikipedia.org/wiki/MQTT\n- https://mosquitto.org/\n- https://www.cloudflare.com/\n- https://www.cloudflare.com/products/tunnel/\n\n\n## Step-by-Step Guide for Navigating Cloudflare\n\nThe 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.\n\n### Step 1: Log into Cloudflare Zero Trust\n1. Go to the Cloudflare Dashboard and log in with your credentials.\n2. In the left sidebar, click on **\"Zero Trust\"**.\n\n   ![Zero Trust](assets/1.png)\n\n### Step 2: Create a Tunnel\n1. Under the **\"Networks\"** section in the sidebar, select **\"Tunnels\"**.\n2. Click on **\"Create a tunnel\"**.\n\n   ![Create Tunnel](assets/2.png)\n\n3. On the next screen, select **\"Cloudflared\"** as the tunnel type and click **\"Next\"**.\n\n   ![Select Cloudflared](assets/3.png)\n\n4. Enter a name for your tunnel, such as `my_tunnel_name`, and click **\"Save tunnel\"**.\n\n   ![Name Tunnel](assets/4.png)\n\n5. Choose **\"Docker\"** as your environment. Copy the provided Docker command which includes your unique token.\n\n   ![Run Connector](assets/5.png)\n\n  Create an `.env` file in the base directory of this repo, and add `CLOUDFLARE_TUNNEL_TOKEN=your_token`.  See [.env.sample](.env.sample) for example.\n\n  _Note: You do not need to run the provided Docker command on the screen. This repository replaces that step._\n\n### Step 3: Set Up Public Hostname\n1. After running the connector, navigate to the **\"Tunnels\"** section again and select the newly created tunnel.\n2. Click on **\"Next\"** to proceed to the hostname configuration.\n\n3. On the **\"Public Hostname Page\"**, fill in the required details:\n   - **Public hostname**: Choose your desired subdomain and domain.\n   - **Service**: Select the service type (HTTP).\n   - **URL**: Set the URL to point to your Mosquitto service (e.g., `mosquitto:9001`). Docker will route the `mosquitto` hostname to the relevant `container_name` in the `docker-compose.yml`.\n\n   ![Public Hostname](assets/6.png)\n\n4. Click **\"Save hostname\"** to finalize the configuration.\n\n### Step 4: Spin up the Containers\n\n```bash\ndocker compose up\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjzombie%2Fdocker-mqtt-mosquitto-cloudflare-tunnel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjzombie%2Fdocker-mqtt-mosquitto-cloudflare-tunnel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjzombie%2Fdocker-mqtt-mosquitto-cloudflare-tunnel/lists"}