1. Caddy version (2.3.0):
2. How I run Caddy:
In Docker on a pi 3B.
a. System environment:
Docker version 20.10.5, build 55c4c88
b. Command:
c.compose file:
version: "3"
services:
caddy:
image: caddy:latest
ports:
- "80:80/tcp"
- "443:443/tcp"
- "50006:50006/tcp"
- "55001:55001/tcp"
environment:
TZ: 'Europe/Berlin'
volumes:
- '/home/pi/docker/caddyv2/data:/data'
- '/home/pi/docker/caddyv2/www:/www'
- '/home/pi/docker/caddyv2/config:/config'
- '/home/pi/docker/caddyv2/Caddyfile:/etc/caddy/Caddyfile'
restart: always
d. My complete Caddyfile or JSON config:
home.domain.de {
log {
output file /data/log/home.domain.de.access.log {
roll_keep_for 7d
}
}
handle_path /webdav/* {
reverse_proxy 192.178.1.12:5005
}
handle_path /dsm/* {
reverse_proxy 192.178.1.12:5000
}
root * /www/home/
file_server
}
home.domain.de:55001 {
#DSM
reverse_proxy 192.178.1.12:5000
}
home.domain.de:50006 {
#secure WebDAV
reverse_proxy 192.178.1.12:5005
}
3. The problem I’m having:
The handle_path directive for /webdav/* is not working, while the one for /dsm/* is. For reasons unknown to me I end up somewhere on the target system (a Synology NAS, but not on the expected webdav service/port).
The port rule below for webdav on the other hand works flawlessly.
I read in another post, that this may be related to the (webdav) application,so only port/subdomain based proxying is possible. Does anyone know if this is supposed to work with synology?
4. Error messages and/or full log output:
curl -v https://home.domain.de/webdav/
* Expire in 0 ms for 6 (transfer 0x14298b0)
* Expire in 1 ms for 1 (transfer 0x14298b0)
* Expire in 0 ms for 1 (transfer 0x14298b0)
* Expire in 1 ms for 1 (transfer 0x14298b0)
* Expire in 0 ms for 1 (transfer 0x14298b0)
* Expire in 0 ms for 1 (transfer 0x14298b0)
* Expire in 2 ms for 1 (transfer 0x14298b0)
* Expire in 0 ms for 1 (transfer 0x14298b0)
* Expire in 0 ms for 1 (transfer 0x14298b0)
* Expire in 2 ms for 1 (transfer 0x14298b0)
* Expire in 0 ms for 1 (transfer 0x14298b0)
* Expire in 0 ms for 1 (transfer 0x14298b0)
* Expire in 2 ms for 1 (transfer 0x14298b0)
* Expire in 0 ms for 1 (transfer 0x14298b0)
* Expire in 0 ms for 1 (transfer 0x14298b0)
* Expire in 2 ms for 1 (transfer 0x14298b0)
* Expire in 0 ms for 1 (transfer 0x14298b0)
* Expire in 0 ms for 1 (transfer 0x14298b0)
* Expire in 2 ms for 1 (transfer 0x14298b0)
* Expire in 1 ms for 1 (transfer 0x14298b0)
* Expire in 1 ms for 1 (transfer 0x14298b0)
* Expire in 1 ms for 1 (transfer 0x14298b0)
* Trying 217.235.138.238...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x14298b0)
* Connected to home.domain.de (217.235.138.238) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_CHACHA20_POLY1305_SHA256
* ALPN, server accepted to use h2
* Server certificate:
* subject: CN=home.domain.de
* start date: Apr 13 00:00:00 2021 GMT
* expire date: Jul 12 23:59:59 2021 GMT
* subjectAltName: host "home.domain.de" matched cert's "home.domain.de"
* issuer: C=AT; O=ZeroSSL; CN=ZeroSSL ECC Domain Secure Site CA
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x14298b0)
> GET /webdav/ HTTP/2
> Host: home.domain.de
> User-Agent: curl/7.64.0
> Accept: */*
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 404
< content-type: text/html; charset=iso-8859-1
< date: Mon, 19 Apr 2021 21:01:26 GMT
< server: Caddy
< server: Apache
< content-length: 196
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>
* Connection #0 to host home.domain.de left intact
Caddy access log:
{"level":"error","ts":1618867392.3171694,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"192.178.1.1:61804","proto":"HTTP/2.0","method":"GET","host":"home.domain.de","uri":"/webdav/","headers":{"Te":["trailers"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"],"Accept-Language":["de,en-US;q=0.7,en;q=0.3"],"Accept-Encoding":["gzip, deflate, br"],"Dnt":["1"],"Upgrade-Insecure-Requests":["1"]},"tls":{"resumed":false,"version":772,"cipher_suite":4867,"proto":"h2","proto_mutual":true,"server_name":"home.domain.de"}},"common_log":"192.178.1.1 - - [19/Apr/2021:21:23:12 +0000] \"GET /webdav/ HTTP/2.0\" 404 196","duration":0.015781586,"size":196,"status":404,"resp_headers":{"Server":["Caddy","Apache"],"Content-Length":["196"],"Content-Type":["text/html; charset=iso-8859-1"],"Date":["Mon, 19 Apr 2021 21:23:12 GMT"]}}
5. What I already tried:
I tried rewrite and redir also uri directive strip_prefix, but none seem to work. I fail also to understand where Caddy actually routes the request.