1. Caddy version (caddy version
):
v2.4.2 h1:chB106RlsIaY4mVEyq9OQM5g/9lHYVputo/LAX2ndFg=
2. How I run Caddy:
I use caddy’s docker container:
FROM caddy
WORKDIR /
COPY ./dist /dist
COPY Caddyfile /Caddyfile
VOLUME /data
CMD ["caddy", "run", "--config", "/Caddyfile"]
a. System environment:
Docker
b. Command:
CMD ["caddy", "run", "--config", "/Caddyfile"]
d. My complete Caddyfile or JSON config:
{
auto_https off
}
:8080 {
log {
# output stdout
# format console
level debug
}
root * /dist
try_files {path} /index.html
file_server
# tls alexey@fluence.one
encode zstd gzip
}
3. The problem I’m having:
I expect a request to localhost:8080/
to return contents of /index.html
. Instead, it is redirected back to /
causing ERR: Too many redirects
in browsers.
~$ curl -v http://localhost:8080/
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 308 Permanent Redirect
< Content-Type: text/html; charset=utf-8
< Location: /
< Server: Caddy
< Date: Fri, 18 Jun 2021 14:01:55 GMT
< Content-Length: 37
<
<a href="/">Permanent Redirect</a>.
* Connection #0 to host localhost left intact
Any other path but /
works fine:
~$ curl -v http://localhost:8080/abc
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /abc HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 864
< Content-Type: text/html; charset=utf-8
< Etag: "quwe55o0"
< Last-Modified: Fri, 18 Jun 2021 12:46:17 GMT
< Server: Caddy
< Date: Fri, 18 Jun 2021 14:02:22 GMT
<
<!doctype html><html lang="en"><head><link rel="favicon" type="image/ico" href="images/favicon.ico"/><link rel="preconnect" href="https://fonts.gstatic.com"><link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@200;400;500&display=swap" rel="stylesheet"><meta charset="utf-8"><meta http-equiv="x-ua-compatible" content="ie=edge"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><title>Fluence Network Dashboard</title></head><body><script async src="https://www.googletagmanager.com/gtag/js?id=G-6ZTQKE1D4L"></script><script>window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
* Connection #0 to host localhost left intact
gtag('config', 'G-6ZTQKE1D4L');</script><div id="root"></div><script src="/main-afbb396dfe01d2336e41.js"></script></body></html>%
4. Error messages and/or full log output:
5. What I already tried:
I’ve tried to add rewrite / /index.html
:
{
auto_https off
}
:8080 {
log {
# output stdout
# format console
level debug
}
root * /dist
rewrite / /index.html # <= this
try_files {path} /index.html
file_server
# tls alexey@fluence.one
encode zstd gzip
}
6. Links to relevant resources:
To reproduce, you can to the repository: GitHub - fluencelabs/dashboard at debug_caddy
checkout branch caddy_debug
, and then
npm i
npm run prod
docker build -f caddy.Dockerfile -t dashboard .
docker run --rm -p8080:8080 -p80:80 -p2019:2019 dashboard