1. The problem I’m having:
I am a caddy beginner and have created a simple Caddyfile .
As expected, everything works right away:
- the local certification is created
- index.html is delivered at https://localhost/
- Changes are visible immediately
My goal is to create a JSON configuration.
I checked the autosave.json and created a file caddy.json in the caddy root directory.
When I remove the Caddyfile and restart Caddy I would expect Caddy to use the caddy.json file.
Instead I receive an error 404 page not found for http and This site can’t be reached
localhost refused to connect. for https and no local certs are created.
What have I done wrong?
Thanks
2. Error messages and/or full log output:
This site can’t be reached
**localhost** refused to connect.
3. Caddy version:
Windows
v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
4. How I installed and ran Caddy:
a. System environment:
caddy.HomeDir=C:\Users\user
caddy.AppDataDir=C:\Users\user\AppData\Roaming\Caddy
caddy.AppConfigDir=C:\Users\user\AppData\Roaming\Caddy
caddy.ConfigAutosavePath=C:\Users\user\AppData\Roaming\Caddy\autosave.json
caddy.Version=v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
runtime.GOOS=windows
runtime.GOARCH=amd64
runtime.Compiler=gc
runtime.NumCPU=8
runtime.GOMAXPROCS=8
runtime.Version=go1.20.3
os.Getwd=C:\Users\user\Desktop\caddy
b. Command:
.\caddy_windows_amd64.exe run
d. My complete Caddy config:
localhost
root * ./www/html
file_server browse
{"apps":
{"http":
{"servers":
{"srv0":
{"listen":
[":443"],
"routes":
[{"handle":
[{"handler":"subroute","routes":
[{"handle":
[{"handler":"vars","root":"./www/html"},
{"browse":{},
"handler":"file_server","hide":[".\\Caddyfile"]}
]}
]}
],
"match":[{"host":["localhost"]}],
"terminal":true}
]}
}
}
}
}