1. Caddy version (caddy version
):
v2.0.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
2. How I run Caddy:
Official docker :latest
container
a. System environment:
Docker on Ubuntu 18.04
d. My complete Caddyfile or JSON config:
The config is available at JSON Editor Online - view, edit and format JSON online - my copy/paste was rejected as too long (and JSON Editor Online allows for an easier parsing on the right panel)
The pastebin version: https://pastebin.com/5C5Mz5Cb
3. The problem I’m having:
When pushing this config, I get an error message which I do not understand
4. Error messages and/or full log output:
{"level":"info","ts":1591719359.3990326,"logger":"admin.api","msg":"received request","method":"POST","host":"192.168.10.2:2020","uri":"/load","remote_addr":"192.168.10.72:62530","headers":{"Accept":["*/*"],"Accept-Encoding":["gzip, deflate"],"Connection":["keep-alive"],"Content-Length":["8846"],"Content-Type":["application/json"],"User-Agent":["python-requests/2.23.0"]}}
{"level":"info","ts":1591719359.4047804,"logger":"admin","msg":"admin endpoint started","address":"tcp/:2020","enforce_origin":false,"origins":["192.168.10.2:2020"]}
{"level":"warn","ts":1591719359.4048088,"logger":"admin","msg":"admin endpoint on open interface; host checking disabled","address":"tcp/:2020"}
{"level":"error","ts":1591719359.4052544,"logger":"admin.api","msg":"request error","error":"loading config: loading new config: loading http app module: decoding module config: http: json: cannot unmarshal array into Go struct field Server.servers.routes of type caddyhttp.Route","status_code":400}
{"level":"info","ts":1591719359.9052434,"logger":"admin","msg":"stopped previous server"}
I do not understand where exactly the error is, the main problem being that the error messsage does not point to a specific part of the configuration.
I see that it is in loading http app module: decoding module config: http: json: cannot unmarshal array into Go struct field Server.servers.routes of type caddyhttp.Route
→ so there is a weird array somewhere in the routes but I cannot see anything wrong (especially when looking at the right panel of the jsoneditoronline.com link above).
These routes come from an otherwise working setup - I just re-coded the whole thing to make it simpler to generate the routes and must have missed something.
The general idea is that caddy works as a reverse proxy. Most routes are split into LAN and non-LAN traffic (the LAN goes to the upstream server, the non-LAN returns a 200 and a space), and some are not split (in whihc case there is a match on 0.0.0.0/0
which leads to the upstream). There are a few exceptions but that’s a general idea - I am writing this so that the setup makes more sense.