abiosoft / caddy-docker

Docker container for Caddy
https://hub.docker.com/r/abiosoft/caddy/
MIT License
768 stars 315 forks source link

Cloudflare DNS provider not installing #121

Closed BuckinghamIO closed 5 years ago

BuckinghamIO commented 6 years ago

I keep getting Unsupported DNS provider even though I am setting cloudflare in the plugins build arg

I've tried setting it in my compose file and also in the docker file but it never gets installed?

mm_nginx: build: context: ./containers/caddy args: plugins: "cloudflare,git,filemanager,cors,realip,expires,cache" image: registry.hub.docker.com/buckinghamio/minecraftmarket-nginx:${BUILD_TAG:-latest} container_name: mm-nginx restart: unless-stopped depends_on:

ARG plugins="cloudflare,git,filemanager,cors,realip,expires,cache" FROM abiosoft/caddy

andrevandal commented 6 years ago

Hi, did you try to use tls.dns.cloudflare instead of cloudflare ?

abiosoft commented 6 years ago

Actually, cloudfare is the correct one.

Hi, did you try to use tls.dns.cloudflare instead of cloudflare ?

@BuckinghamIO set build as github.com/abiosoft/caddy-docker instead. You don't need a separate Dockerfile.

andrevandal commented 6 years ago

@abiosoft I made a fork and add cloudflare as build args in dockerfile to use on my swarm...

ARG plugins="git,filemanager,cors,realip,expires,cache,docker,datadog,minify,nobots,prometheus,ratelimit,webdav,cloudflare"

And error still apears:

/etc/Caddyfile:3 - Error during parsing: Unsupported DNS provider 'cloudflare'
FlorianWendelborn commented 6 years ago

@BuckinghamIO @derevandal Works fine for my local dev environment: https://github.com/dodekeract/cloudflocaddy

Maybe this can help you troubleshoot the issue?

njm2112 commented 5 years ago

@BuckinghamIO @derevandal: were either of you able to get this working? I am having the same problem now and no success using tls.dns.cloudflare either. Config details below (with tls directive in the common.conf item). I would greatly appreciate your input if you were able to find a solution to this. BR/

[EDITED] I think I see what's happening. Despite the declaration of the - plugins= argument for the build command, when I run docker-compose -f /path/to/docker-compose.yml up, the cloudflare plugin is not being installed. Here's the relevant part of the transcript:

su_nas@NAS01:~$ sudo docker-compose -f /volume1/docker/caddy/build/docker-compose.yml / 
up --build
Building caddy
Step 1/22 : FROM abiosoft/caddy:builder as builder
 ---> cbef2b88c51c
Step 2/22 : ARG version="0.11.0"
 ---> Using cache
 ---> 3bd82d16154e
Step 3/22 : ARG plugins="git,filemanager,cors,realip,expires,cache"
 ---> Using cache
 ---> 0a635036e345

cc: @abiosoft

docker-compose.yml

# object: docker-compose.yml - v0.3 (20180920225844)
# server: /volume1/docker/caddy/build/docker-compose.yml
# container: _not mapped_
# Comments: See notes/commentary on which these updates were based at
#           [Caddy.community](https://caddy.community/t/caddy-via-docker-as-reverse-proxy-to-gitea-instance-on-private-server/4438/2)
# Usage:  First-time run using `docker-compose -f /path/to/docker-compose.yml up`; end using `Ctrl + C`.
#         Subsequent run using `docker-compose  -f /path/to/docker-compose.yml up -d`.
#
version: '3'

services:
  caddy:
    build:
      context: github.com/abiosoft/caddy-docker.git
      args:
        - plugins=git,cloudflare,jwt,login,filter,cors,realip,filemanager,cache,expires
    command: ["-log", "stdout", "-agree",
      "-email", "letsencrypt@mydomain.xyz",
      "-conf", "/etc/Caddyfile"]
    ports:
      - 8881:80/tcp
      - 4444:443/tcp
    environment:
      CLOUDFLARE_EMAIL: cloudflare@mydomain.xyz
      CLOUDFLARE_API_KEY: [snip]
    volumes:
      - /volume1/docker/caddy/config/Caddyfile:/etc/Caddyfile
      - /volume1/docker/caddy/config/common.conf:/etc/common.conf
      - /volume1/docker/caddy/certs:/root/.caddy
      - /volume1/docker/caddy/public:/srv
      - /volume1/docker/caddy/logs:/var/log/caddy
# gitea:          # Not adding these to the docker-compose instructions as of now
# monica:         # because they are pre-built, working services but will add them
# mysql:          # once I get Caddy functioning properly.

common.conf

# Object: common.conf v0.3-20180920225844
# Local: /volume1/docker/caddy/config/common.conf
# Container: /etc/caddy/common.conf
# Objective: To minimize repetitive code blocks within the Caddyfile where the settings for a given service /
# proxy are the same. Instead, in each such instance we will use `import common.conf`.
# Comments:
#
tls letsencrypt@mydomain.xyz
tls {
     dns cloudflare
    }

gzip

log /var/log/caddy/access.log "{remote} - {user} [{when}] {host} \(\"{>Referrer}\" \"{>User-Agent}\"\) \"{method} {uri} {proto}\" {status} {size}" {
         rotate_size 2            
         rotate_age  7            
         rotate_keep 2            
    }
errors {
    log /var/log/caddy/error.log "{remote} - {user} [{when}] {host} \(\"{>Referrer}\" \"{>User-Agent}\"\) \"{method} {uri} {proto}\" {status} {size}" {
         rotate_size 2             
         rotate_age  7             
         rotate_keep 2             
         }
    }

header / {
  Strict-Transport-Security "max-age=31536000; includeSubDomains"
  X-XSS-Protection "1; mode=block"
  X-Content-Type-Options "nosniff"
  X-Frame-Options "DENY"
 -Server
    }

Caddyfile

# Object: Caddyfile v0.4-20180920225844
# Server: /volume1/docker/caddy/config/Caddyfile
# Container: /etc/caddy/Caddyfile
# Comments:

mydomain.xyz {
  root /srv
  import /etc/common.conf

  redir 301 {
    / https://www.google.com/   # Redirect from mydomain.xyz to Google with https since Google
                                # automatically redirects http --> https anyway.

    /git    https://git.mydomain.xyz
    /gitea  https://git.mydomain.xyz
    /plex   https://plex.mydomain.xyz
    /dsm    https://syno.mydomain.xyz
    /syno   https://syno.mydomain.xyz
#   /monica https://crm.mydomain.xyz     # Service not yet setup
    }
}

http://, https:// {
    tls self_signed
    header / -Server
    }

syno.mydomain.xyz {             # Synology DSM
  import /etc/common.conf
  basicauth [snip] [snip]
  proxy / my-local-ip:5000 {
    transparent
  }
}

git.mydomain.xyz {              # Gitea
  import /etc/common.conf
  basicauth [snip] [snip]
  proxy / my-local-ip:33000 {
    transparent
  }
}

plex.mydomain.xyz {             # Plex
  import /etc/common.conf
# basicauth [snip] [snip]
  proxy / my-local-ip:32400 {
    transparent
  }
}
abiosoft commented 5 years ago

Are you still having this issue?