1. Caddy version (caddy version
): v2.4.5
2. How I run Caddy:
a. System environment:
Windows 10: OS Build 19042.1237
b. Command:
caddy2 run --watch
c. My complete Caddyfile or JSON config:
CaddyFile
localhost:8080 {
handle /api/v1/ {
reverse_proxy localhost:3000
}
handle /api/v2/ {
reverse_proxy localhost:3001
}
}
autosave.json
{
"apps":{
"http":{
"servers":{
"srv0":{
"listen":[
":8080"
],
"routes":[
{
"handle":[
{
"handler":"subroute",
"routes":[
{
"group":"group2",
"handle":[
{
"handler":"subroute",
"routes":[
{
"handle":[
{
"handler":"reverse_proxy",
"upstreams":[
{
"dial":"localhost:3000"
}
]
}
]
}
]
}
],
"match":[
{
"path":[
"/api/v1/"
]
}
]
},
{
"group":"group2",
"handle":[
{
"handler":"subroute",
"routes":[
{
"handle":[
{
"handler":"reverse_proxy",
"upstreams":[
{
"dial":"localhost:3001"
}
]
}
]
}
]
}
],
"match":[
{
"path":[
"/api/v2/"
]
}
]
}
]
}
],
"match":[
{
"host":[
"localhost"
]
}
],
"terminal":true
}
]
}
}
}
}
}
3. The problem I’m having:
Im trying to setup a web server using caddy that act as a proxy for two endpoints that I’m running using express. However, I’m having difficulties installing the root certificate.
4. Error messages and/or full log output:
2021/10/05 12:18:48.149 INFO using adjacent Caddyfile
2021/10/05 12:18:48.150 WARN input is not formatted with 'caddy fmt' {"adapter": "caddyfile", "file": "Caddyfile", "line": 1}
2021/10/05 12:18:48.155 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2021/10/05 12:18:48.155 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc000392930"}
2021/10/05 12:18:48.155 INFO http enabling automatic HTTP->HTTPS redirects {"server_name": "srv0"}
2021/10/05 12:18:48.157 INFO tls cleaning storage unit {"description": "FileStorage:C:\\Users\\User\\AppData\\Roaming\\Caddy"}
2021/10/05 12:18:48.158 INFO tls finished cleaning storage units
2021/10/05 12:18:48.171 WARN pki.ca.local installing root certificate (you might be prompted for password) {"path": "storage:pki/authorities/local/root.crt"}
2021/10/05 20:18:48 Note: NSS support is not available on your platform
2021/10/05 12:18:48.621 ERROR pki.ca.local failed to install root certificate {"error": "add cert failed: Failed adding cert: Access is denied.", "certificate_file": "storage:pki/authorities/local/root.crt"}
2021/10/05 12:18:48.622 INFO http enabling automatic TLS certificate management {"domains": ["localhost"]}
2021/10/05 12:18:48.623 WARN tls stapling OCSP {"error": "no OCSP stapling for [localhost]: no OCSP server specified in certificate"}
2021/10/05 12:18:48.623 INFO autosaved config (load with --resume flag) {"file": "C:\\Users\\User\\AppData\\Roaming\\Caddy\\autosave.json"}
2021/10/05 12:18:48.624 INFO serving initial configuration
2021/10/05 12:18:48.624 INFO watcher watching config file for changes {"config_file": "Caddyfile"}
5. What I already tried:
caddy2 trust
logs when run above command
2021/10/05 12:20:09.091 WARN ca.local installing root certificate (you might be prompted for password) {"path": "storage:pki/authorities/local/root.crt"}
2021/10/05 20:20:09 Note: NSS support is not available on your platform
trust: add cert failed: Failed adding cert: Access is denied.