# Step-by-Step to configure Traefik on Unraid via Cloudflare tunnels

**URL:** <https://forum.hhf.technology/t/step-by-step-to-configure-traefik-on-unraid-via-cloudflare-tunnels/84>\
**Category:** Tutorials\
**Tags:** cloudflare-tunnels, unraid, traefik\
**Created:** [October 9, 2024, 10:47am UTC](https://forum.hhf.technology/t/step-by-step-to-configure-traefik-on-unraid-via-cloudflare-tunnels/84 "2024-10-09T10:47:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hhf.technoloy](https://forum.hhf.technology/user_avatar/forum.hhf.technology/hhf.technoloy/32/68_2.png) [@hhf.technoloy](https://forum.hhf.technology/u/hhf.technoloy)\
**Post date:** [October 9, 2024, 10:47am UTC](https://forum.hhf.technology/t/step-by-step-to-configure-traefik-on-unraid-via-cloudflare-tunnels/84/1 "2024-10-09T10:47:03Z")

</div>

Got it! Let’s go through the process of setting up Cloudflare tunnels using the Cloudflare Tunnel Community App on Unraid, and then configuring Traefik to route traffic through these tunnels.

### Step 1: Install Cloudflare Tunnel Community App

1. **Install Cloudflare Tunnel App** :

2. **Configure Cloudflare Tunnel** :

### Step 2: Create Cloudflare Tunnel

1. **Create a Cloudflare Tunnel** :

2. **Configure the Tunnel in the App** :

### Configure DNS Records in Cloudflare

1. **Add CNAME Records** :
  - Go to the **DNS** settings in your Cloudflare dashboard.
  - Add a CNAME record for each subdomain you want to use for your apps (e.g., `app1.domain.com`, `app2.domain.com`), pointing to `@` (your root domain).

### Step 4: Set Up Traefik

1. **Install Traefik on Unraid** :

2. **Create Traefik Configuration Files** :

3. **traefik.yml** :

4. **dynamic.yml** :

5. **Docker Labels** :

### Step 5: Start Traefik

1. **Run Traefik Docker Container** :

2. **Access the Dashboard** :

### Step 6: Configure Cloudflare API Token

1. **Create API Token** :
  - In Cloudflare, go to **My Profile** → **API Tokens**.
  - Create a new API token with permissions to manage DNS for your domain.
  - Use this token in the `traefik.yml` file under the DNS challenge configuration.

### Example Configuration Files

#### `traefik.yml`

```yaml
api:
  dashboard: true

entryPoints:
  web:
    address: ":80"
  websecure:
    address: ":443"

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false

certificatesResolvers:
  cloudflare:
    acme:
      email: your-email@example.com
      storage: acme.json
      dnsChallenge:
        provider: cloudflare
        resolvers:
          - "1.1.1.1"

```

#### `dynamic.yml`

```yaml
http:
  routers:
    app1:
      rule: "Host(`app1.domain.com`)"
      service: app1
      entryPoints:
        - websecure
      tls:
        certResolver: cloudflare

    app2:
      rule: "Host(`app2.domain.com`)"
      service: app2
      entryPoints:
        - websecure
      tls:
        certResolver: cloudflare

  services:
    app1:
      loadBalancer:
        servers:
          - url: "http://app1:8080"
    app2:
      loadBalancer:
        servers:
          - url: "http://app2:8080"

```

This setup should help you get Traefik running on Unraid with Cloudflare tunnels, allowing you to access your apps via subdomains.
