1. Caddy version (2.4.3
):
2. How I run Caddy:
caddy run --watch
a. System environment:
Ubuntu 20.04.2 LTS
b. Command:
caddy run --watch
c. Service/unit/compose file: NA
d. My complete Caddyfile or JSON config:
-
None functioning Caddyfile
- If I use this setting and access the localhost explicitly by
http://localhost
I get a blank page, no errors written in the log file nor shown on the by the browser when a web browser is used. - however if I do curl -v
http://localhost
the index.html gets served with identical output for both Caddyfile …
- If I use this setting and access the localhost explicitly by
{
auto_https off
}
http://localhost:80 {
log {
output file /etc/caddy/test/site/caddy.log
}
root * /etc/caddy/test/site
file_server
}
-
Functioning Caddyfile
- If I use this setting and access the localhost explicitly by writing
http://localhost
on the web browser, the web page loads and the logger outputs in to the log file as expected.
- If I use this setting and access the localhost explicitly by writing
{
auto_https off
}
:80 {
log {
output file /etc/caddy/test/site/caddy.log
}
root * /etc/caddy/test/site
file_server
}
3. The problem I’m having:
Basically I am trying to host local websites for dev/prototype purposes. I found myself not being able to access the site through the https, getting SSL certificate error in Firefox when I try to access my local server no matter what I do, even this won’t work:
localhost
respond "hello"
As a result I decided to turn off auto_https as it was not necessary for my needs, and followed the https guidance on the wiki here, it only works if I only specify the port of my choice otherwise I get an empty page…
- How do I access
https://localhost
without getting any error? I really tried everything on the forum and searched everywhere. I thought https/TLS was suppose to be all magical and automatic with caddy… - Why is the website not loaded when I use
http://localhost:80
vs :80 as the domain address
4. Error messages and/or full log output:
- Firefox output
- curl -v for BOTH configurations
* Trying 127.0.0.1:80...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 23
< Content-Type: text/html; charset=utf-8
< Etag: "qygj0tn"
< Last-Modified: Thu, 26 Aug 2021 17:24:29 GMT
< Server: Caddy
< Date: Thu, 26 Aug 2021 22:43:16 GMT
<
<h1>hello world</h1>
* Connection #0 to host localhost left intact
5. What I already tried:
- Making sense of `auto_https` and why disabling it still serves HTTPS instead of HTTP
- all ports used by caddy are open on my machine, including the :80 and :443 (I used ufw to enable them)
- I used
sudo setcap 'cap_net_bind_service=+ep' /usr/bin/caddy
to give caddy access to the privileged ports so that I could use https|:443 initially which it didn’t work (browsers giving error about the certificate…) but at least I could access the http port if I only use :80 as the domain. - I even allowed caddy to have read/write/execute access to all the files involved just in case if that was the issue (which I believe is very unlikely as the server works on other occasions)