1. Caddy version (caddy version
):
v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=
2. How I run Caddy:
a. System environment:
Windows 8, running it from powerShell, installed with choco
b. Command:
caddy run
c. Service/unit/compose file:
I think it's not relevant here?
d. My complete Caddyfile or JSON config:
{
"apps": {
"http": {
"servers": {
"example": {
"listen": [
"127.0.0.1:2137"
],
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"load_balancing": {
"selection_policy": {
"policy": "round_robin"
}
},
"upstreams": [
{
"dial": "127.0.0.1:8444"
},
{
"dial": "127.0.0.1:8445"
}
]
}
]
}
]
}
}
}
}
}
3. The problem Iām having:
I would expect it to proxy all request sent to localhost:2137
to either 8444
or 8445
, but thatās not really happening. Iām running my backend on those ports, so I should receive some data, even if request is unauthorized.
If that helps, Iām not sending requests to just localhost:8444
, but for example localhost:8444/authenticate
Tried with browser, postman and curl
curl -X POST https://localhost:8444/authenticate/debug -k
This works, (or just throws some error)
So I would expect that this:
curl -X POST http://localhost:2137/authenticate/debug -k
or this
curl -X POST https://localhost:2137/authenticate/debug -k
Would work too
4. Error messages and/or full log output:
If I request for https I get
curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number
But http
returns nothing.
Hereās caddy output
2022/03/23 14:04:21.255 ā[34mINFOā[0m admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2022/03/23 14:04:21.255 ā[34mINFOā[0m serving initial configuration
2022/03/23 14:04:30.607 ā[34mINFOā[0m admin.api received request {"method": "POST", "host": "localhost:2019", "uri": "/load", "remote_addr": "127.0.0.1:55108", "headers": {"Accept":["*/*"],"Content-Length":["492"],"Content-Type":["application/json"],"User-Agent":["curl/7.70.0"]}}
2022/03/23 14:04:30.608 ā[34mINFOā[0m admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["[::1]:2019", "127.0.0.1:2019", "localhost:2019"]}
2022/03/23 14:04:30.608 ā[34mINFOā[0m tls.cache.maintenance started background certificate maintenance {"cache": "0xc00016fc70"}
2022/03/23 14:04:30.608 ā[34mINFOā[0m tls cleaning storage unit {"description": "FileStorage:C:\\Users\\Jarek\\AppData\\Roaming\\Caddy"}
2022/03/23 14:04:30.609 ā[34mINFOā[0m autosaved config (load with --resume flag) {"file": "C:\\Users\\Jarek\\AppData\\Roaming\\Caddy\\autosave.json"}
2022/03/23 14:04:30.613 ā[34mINFOā[0m admin.api load complete
2022/03/23 14:04:30.612 ā[34mINFOā[0m tls finished cleaning storage units
2022/03/23 14:04:30.623 ā[34mINFOā[0m admin stopped previous server {"address": "tcp/localhost:2019"}
2022/03/23 14:04:39.536 ā[31mERRORā[0m http.log.error EOF {"request": {"remote_addr": "127.0.0.1:55614", "proto": "HTTP/1.1", "method": "POST", "host": "localhost:2137", "uri": "/authenticate/debug", "headers": {"Accept": ["*/*"], "User-Agent": ["curl/7.70.0"]}}, "duration": 0.0013792, "status": 502, "err_id": "mu4jgvkdq", "err_trace": "reverseproxy.statusError (reverseproxy.go:886)"}
5. What I already tried:
Switching up addresses in config. Tried 127.0.0.1
, localhost
, http://localhost
, https://localhost
None of those really helped.
Iām new to Caddy, donāt know that much about networing, and docs for JSON configs are kind of hard to understand (at least for someone who installed caddy 3 hours ago).
I would go with Caddyfile, but Iāve been told that I will have to create my own .go
plugin later on (upstream selection based on decoded token + some basic math), and based on this source: https://caddyserver.com/docs/getting-started it seems that it would be easier to do with JSON