{"id":20443921,"url":"https://github.com/jonas-merkle/container-cloudflare-tunnel","last_synced_at":"2025-04-07T13:05:28.758Z","repository":{"id":142777627,"uuid":"610217596","full_name":"jonas-merkle/container-cloudflare-tunnel","owner":"jonas-merkle","description":"A Docker Compose container setup for a Cloudflare tunnel.","archived":false,"fork":false,"pushed_at":"2025-02-15T09:38:13.000Z","size":56,"stargazers_count":77,"open_issues_count":1,"forks_count":20,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T12:09:31.921Z","etag":null,"topics":["cloudflare","cloudflare-tunnel","cloudflared","docker","docker-compose","tunnel"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonas-merkle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":"jonas-merkle","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-03-06T10:32:19.000Z","updated_at":"2025-03-30T14:52:17.000Z","dependencies_parsed_at":"2024-11-14T20:26:05.639Z","dependency_job_id":"3f103137-61bc-4c84-9334-cbc83cb3aabf","html_url":"https://github.com/jonas-merkle/container-cloudflare-tunnel","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonas-merkle%2Fcontainer-cloudflare-tunnel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonas-merkle%2Fcontainer-cloudflare-tunnel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonas-merkle%2Fcontainer-cloudflare-tunnel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonas-merkle%2Fcontainer-cloudflare-tunnel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonas-merkle","download_url":"https://codeload.github.com/jonas-merkle/container-cloudflare-tunnel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247657276,"owners_count":20974344,"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":["cloudflare","cloudflare-tunnel","cloudflared","docker","docker-compose","tunnel"],"created_at":"2024-11-15T09:49:56.472Z","updated_at":"2025-04-07T13:05:28.739Z","avatar_url":"https://github.com/jonas-merkle.png","language":"Dockerfile","funding_links":["https://github.com/sponsors/jonas-merkle"],"categories":[],"sub_categories":[],"readme":"# Container Cloudflare Tunnel\n\nA Docker Compose container setup for a [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/). This setup allows you to securely expose a local service to the internet using Cloudflare's infrastructure.\n\n\u003cdetails\u003e\n\n\u003csummary\u003eTable of Contents\u003c/summary\u003e\n\n## Table of Contents\n\n- [Container Cloudflare Tunnel](#container-cloudflare-tunnel)\n  - [Table of Contents](#table-of-contents)\n  - [Introduction](#introduction)\n  - [Setup](#setup)\n    - [Requirements](#requirements)\n    - [Environment Variables](#environment-variables)\n      - [How to Obtain the Cloudflare Tunnel Token](#how-to-obtain-the-cloudflare-tunnel-token)\n    - [Hosts Configuration](#hosts-configuration)\n  - [Usage](#usage)\n    - [Starting the Container](#starting-the-container)\n    - [Stopping the Container](#stopping-the-container)\n    - [Viewing Logs](#viewing-logs)\n    - [Cleanup](#cleanup)\n  - [Real-World Examples](#real-world-examples)\n    - [Example 1: Hosting a Webpage with Apache and Docker](#example-1-hosting-a-webpage-with-apache-and-docker)\n    - [Example 2: Secure Self-Hosting with Cloudflare Zero Trust Tunnels](#example-2-secure-self-hosting-with-cloudflare-zero-trust-tunnels)\n  - [Security Notes](#security-notes)\n  - [License](#license)\n  - [Additional Resources](#additional-resources)\n  \n\u003c/details\u003e\n\n## Introduction\n\nCloudflare Tunnel provides a secure way to expose a web server running on your local network to the public internet. This can be particularly useful for development, accessing internal services remotely, or securely publishing a service without opening ports on your router. The container in this project sets up a Cloudflare Tunnel, making it simple to deploy.\n\n## Setup\n\n### Requirements\n\n- Docker\n- Docker Compose\n\nThis setup assumes that [Cloudflare](https://www.cloudflare.com/) is the DNS provider for your domain.\n\n### Environment Variables\n\nAdd the missing information for the environment variables in the `.env` file:\n\n```env\nCLOUDFLARE_TUNNEL_TOKEN=''\n```\n\n- `CLOUDFLARE_TUNNEL_TOKEN`: This token is provided by Cloudflare when you create a new tunnel. Replace `''` with your actual token.\n\n#### How to Obtain the Cloudflare Tunnel Token\n\nTo get the Cloudflare Tunnel token, follow these steps:\n\n1. Log in to your [Cloudflare Dashboard](https://dash.cloudflare.com/).\n2. Navigate to the **Zero Trust** section or **Access** section (depending on the Cloudflare interface).\n3. Select **Tunnels** from the navigation menu.\n4. Click on **Create a Tunnel**.\n5. Follow the on-screen instructions to name your tunnel and select your desired configuration.\n6. Once the tunnel is created, Cloudflare will provide a **Tunnel Token**. Copy this token and paste it into the `.env` file under `CLOUDFLARE_TUNNEL_TOKEN`.\n\nMake sure to edit the `.env` file and add your specific token:\n\n```bash\nnano .env\n```\n\nTo prevent `.env` from being tracked by version control, run the following command:\n\n```bash\ngit update-index --assume-unchanged .env\n```\n\n### Hosts Configuration\n\nModify the `hosts` file if needed to define any custom hostname mappings:\n\n```bash\nnano config/hosts\n```\n\nAdd any additional hosts that need to be mapped within the container. To avoid tracking changes to this file, run:\n\n```bash\ngit update-index --assume-unchanged config/hosts\n```\n\n## Usage\n\n### Starting the Container\n\nTo start the Cloudflare Tunnel container, run:\n\n```bash\ndocker compose up -d\n```\n\nThis command will start the container in detached mode.\n\n### Stopping the Container\n\nTo stop the running container, use:\n\n```bash\ndocker compose down\n```\n\n### Viewing Logs\n\nTo view the logs for the running container, which can help with troubleshooting:\n\n```bash\ndocker logs cloudflare-tunnel\n```\n\n### Cleanup\n\nIf you want to remove all containers, networks, and associated volumes:\n\n```bash\ndocker compose down --volumes --remove-orphans\n```\n\n## Real-World Examples\n\nIf you're looking for a step-by-step guide on how to use Cloudflare Tunnel in a real-world scenario, check out these blog posts:\n\n### Example 1: Hosting a Webpage with Apache and Docker\n\nBy [John Wuller (@2br-2b)](https://github.com/2br-2b):\n\n[**How to Host a Webpage Locally Using Cloudflare Tunnels, Apache, and Docker**](https://codegito.xyz/2024/12/01/cloudflare-apache-docker/)\n\nIn this tutorial, John demonstrates based on this repository:\n\n- Setting up a local webpage with Apache and Docker.\n- Configuring a Cloudflare Tunnel to securely expose the webpage to the internet without requiring port forwarding.\n\n### Example 2: Secure Self-Hosting with Cloudflare Zero Trust Tunnels\n\nBy [Sven van Ginkel](https://medium.com/@svenvanginkel):\n\n[**Self-Hosting Securely with Cloudflare Zero Trust Tunnels**](https://medium.com/@svenvanginkel/self-hosting-securely-with-cloudflare-zero-trust-tunnels-0a9169378f78)\n\nIn this guide, Sven explains the fundamental concepts of Cloudflare Zero Trust Tunnels and provides an in-depth walkthrough of the setup process on Cloudflare’s side. While his Docker Compose configuration is not based on this repository, the core principles remain similar.\n\n## Security Notes\n\n- **Environment Variables**: Ensure that `.env` files are not shared or tracked in version control, as they may contain sensitive information such as API tokens or credentials.\n- **Sensitive Files**: Always keep sensitive files like `.env` secure and ensure they are not exposed publicly.\n\n## License\n\nThis project is licensed under the [**GNU Lesser General Public License v3.0**](https://www.gnu.org/licenses/lgpl-3.0.html) (LGPLv3).\nIt is distributed \"as is\", without warranty of any kind.\nYou are free to use, modify, and distribute this software under the terms specified in the LGPLv3.\n\nSee the [LICENSE](./LICENSE) file for more detailed information.\n\n## Additional Resources\n\n- [Cloudflare Tunnel Documentation](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/): Learn more about how Cloudflare Tunnel works and its various use cases.\n- [Docker Documentation](https://docs.docker.com/): Official Docker documentation for commands and features used in this setup.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonas-merkle%2Fcontainer-cloudflare-tunnel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonas-merkle%2Fcontainer-cloudflare-tunnel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonas-merkle%2Fcontainer-cloudflare-tunnel/lists"}