import{_ as i,c as a,a3 as n,o as l}from"./chunks/framework.DtMx7FFi.js";const e="/cat-typing.gif",g=JSON.parse('{"title":"Cloudflare Tunneling","description":"","frontmatter":{"title":"Cloudflare Tunneling"},"headers":[],"relativePath":"cf-tunnel.md","filePath":"cf-tunnel.md"}'),t={name:"cf-tunnel.md"};function p(h,s,k,E,r,d){return l(),a("div",null,s[0]||(s[0]=[n(`

Cloudflare Tunnel Setup: ​

Sometimes, someone might want to deploy the DP-SALAD stack behind NAT or you don't want to open your network's ports exposing them to the outside.

Note:

You do not need to have your domain registered through Cloudflare to use Cloudflare Tunnels

THE SOLUTION? ​

Cloudflare Tunnels

Of course, running the stack this way comes with some extra configuartion on both the Docker side and Cloudflare/domain side.

This is an excerpt from the One-Click Docker Compose file:

In order to make this work with cloudflare tunneling, you must add some more lines to your docker compose. The first being a directive which is highlighted below:

yml
version: "2.1"
services:
  swag:
    image: lscr.io/linuxserver/swag:latest
    container_name: swag
    cap_add:
      - NET_ADMIN
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Phoenix
      - URL=[sakura.nt]
      - VALIDATION=dns
      - SUBDOMAINS=wildcard
      - DNSPLUGIN=cloudflare
      - EMAIL=[sakurant@gmail.com]
      - ONLY_SUBDOMAINS=false
      #- EXTRA_DOMAINS= #optional
      - STAGING=false
      - DOCKER_MODS=linuxserver/mods:universal-docker|linuxserver/mods:swag-auto-reload|linuxserver/mods:swag-dashboard|linuxserver/mods:swag-dbip|linuxserver/mods:universal-cloudflared
    extra_hosts:
        - domain.tld:127.0.0.1
    volumes:
      - /home/[INSERT USER FOLDER HERE]/appdata/swag:/config
    ports:
      - 443:443
      - 80:80
    networks:
      - [INSERT NETWORK NAME HERE]
    restart: unless-stopped

Next, you'll want to generate an API key with Cloudflare , go to Overview in your domain, and click "get your api token", click Create Token, use → "Edit zone DNS" template, add a permission, select "Account", → "Cloudflare Tunnel", → "Edit", under account resources, include your account, under zone resources, include your domain. Continue with setup, make sure you keep track of the API key somewhere.

After you have completed these steps, you will need to add these credentials to your Swag configuration in the docker-compose.yml. After the Docker_Mods environment variable, add these lines:

yml
version: "2.1"
services:
  swag:
    image: lscr.io/linuxserver/swag:latest
    container_name: swag
    cap_add:
      - NET_ADMIN
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Phoenix
      - URL=[sakura.nt]
      - VALIDATION=dns
      - SUBDOMAINS=wildcard
      - DNSPLUGIN=cloudflare
      - EMAIL=[sakurant@gmail.com]
      - ONLY_SUBDOMAINS=false
      #- EXTRA_DOMAINS= #optional
      - STAGING=false
      - DOCKER_MODS=linuxserver/mods:universal-docker|linuxserver/mods:swag-auto-reload|linuxserver/mods:swag-dashboard|linuxserver/mods:swag-dbip|linuxserver/mods:universal-cloudflared
      - CF_ZONE_ID=zone id from cloudflare domain overview
      - CF_ACCOUNT_ID=account id from cloudflare domain overview
      - CF_API_TOKEN=api token generated
      - CF_TUNNEL_NAME=create a tunnel, name it whatever
      - CF_TUNNEL_PASSWORD=generate a long password
      - FILE__CF_TUNNEL_CONFIG=/config/tunnelconfig.yml
    extra_hosts:
        - domain.tld:127.0.0.1
    volumes:
      - /home/[INSERT USER FOLDER HERE]/appdata/swag:/config
    ports:
      - 443:443
      - 80:80
    networks:
      - [INSERT NETWORK NAME HERE]
    restart: unless-stopped

You're not quite done yet...

You'll need to add more to finish the installation: First, nano /home/[USER]/appdata/swag/tunnelconfig.yml, and add these contents:

yml
ingress:
  - hostname: domain.tld
    service: https://domain.tld
  - hostname: "*.domain.tld"
    service: https://domain.tld
  - service: http_status:404

Then, edit the /home/[USER]/appdata/swag/dns-conf/cloudflare.ini, add the API token, you'll comment the top two lines, add the token after uncommenting the bottom line.

insert funni meeme here:

/cat-typing.gif

',17)]))}const c=i(t,[["render",p]]);export{g as __pageData,c as default};