1. Caddy version (caddy version
):
v2.4.0 h1:yHnnbawH2G3ZBP2mAJF4XBLnJanqhULLP/wu01Qi9Io=
2. How I run Caddy:
Caddy is run as a service using JSON API on Ubunto 20.04
a. System environment:
systemd
b. Command:
It’s automatically started at boot up time
c. Service/unit/compose file:
n/a
d. My complete Caddyfile or JSON config:
I am just posting the relevant information here as it’s too big for the forums to handle:
{
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "rewrite",
"strip_path_prefix": "/axis-home"
}
]
},
{
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Access-Control-Allow-Credentials": [
"true"
],
"Access-Control-Allow-Headers": [
"Cache-Control,Content-Type"
],
"Access-Control-Allow-Origin": [
"*"
],
"X-Forwarded-Proto": [
"{http.request.scheme}"
],
"X-Real-Ip": [
"{http.request.remote.host}"
]
}
}
},
"upstreams": [
{
"dial": "192.168.0.78:80"
}
]
}
]
}
]
}
],
"match": [
{
"path": [
"/axis-home/*"
]
}
]
},
3. The problem I’m having:
I get a 502 Bad Gateway when trying to access
4. Error messages and/or full log output:
From the journal:
May 18 08:02:08 jeff-UX510UX caddy[1103]:
{
"level":"error",
"ts":1621346528.6609566,
"logger":"http.log.error",
"msg":"dial tcp 192.168.0.78:80: connect: no route to host",
"request":
{
"remote_addr":"127.0.0.1:46620",
"proto":"HTTP/1.1",
"method":"POST",
"host":"localhost",
"uri":"/axis-home/onvif/device_service",
"headers":
{
"Connection":["close"],
"Content-Type":["application/soap+xml; charset=utf-8; action=http://www.onvif.org/ver10/device/wsdl/GetSystemDateAndTime"],
"Accept":["*/*"],
"Content-Length":["299"],
"User-Agent":["node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"],
"Accept-Encoding":["gzip,deflate"]
}
},
"duration":3.06392252,
"status":502,
"err_id":"h29psppf5",
"err_trace":"reverseproxy.statusError (reverseproxy.go:852)"
}
5. What I already tried:
The code I am using to access the camera directly via IP address works fine. Once I try to use the reverse proxy, I get the 502 Bad Gateway.