mholt / caddy-webdav

WebDAV handler module for Caddy
Apache License 2.0
228 stars 24 forks source link

Trying to confirm if it's working #6

Closed firedrow closed 4 years ago

firedrow commented 4 years ago

I wanted to see if you could clarify something in my Caddyfile, or maybe build. I cannot get /webdav to work with a docker build of Caddy. When I browse to the docker box, I get my test page. When I go to http://dockerip/static to redirect to /static/ and does the browse plugin. So those are working. When I go to http://dockerip/webdav I'm getting 404.

Is the root element of webdav relative to the site blocks root? or is it a full file path?

My Caddyfile:

{
    order webdav last
}

(global) {
  encode gzip zstd
  log {
    output file /data/logs/caddy_access.log
  }
  handle_errors /data/logs/caddy_errors.log
  php_fastcgi phpfpm:9000
}

:80 {
  root * /usr/share/caddy/html
  file_server
  file_server /static/* browse
  import global

  redir /static /static/

  webdav /webdav {
    root /usr/share/caddy/webdav
  }
}

The Dockerfile builder:

FROM caddy:2.0.0-builder AS builder

RUN caddy-builder \
    github.com/mholt/caddy-webdav

FROM caddy:2.0.0

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

Relevant docker-compose.yml:

version: '3.4'

services:
# Caddy web server, doing reverse proxy
  caddy:
    image: "caddy:2.0.0-custom"
    container_name: "caddy"
    ports:
     - "80:80"
     - "443:443"
    volumes:
     - /srv/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
     - /srv/caddy/www:/usr/share/caddy:rw
     - /srv/caddy/data:/data:rw
    restart: always
mholt commented 4 years ago

Since you ordered webdav last, you're only hitting the file_server. If you're going to use both, you need to put webdav before file_server. (Then again, I don't know why or how you'd use both, since differentiating webdav requests from regular file server requests is ambiguous.)

For more info about directive order, please see this wiki article: https://caddy.community/t/composing-in-the-caddyfile/8291/1