1. Caddy version (caddy version
):
v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=
2. How I run Caddy:
Pure, clean installation, except with the Cloudflare module added via add-package
command.
ASP.NET API running at localhost:500
(http) and localhost:5001
(https)
a. System environment:
- Debian 10
b. Command:
caddy run
or
caddy start
c. Service/unit/compose file:
N/A
d. My complete Caddyfile or JSON config:
images.genfic.net {
tls {
dns cloudflare [Cloudflare Token]
}
reverse_proxy 127.0.0.1:5001 {
header_up Host {upstream_hostport}
header_up X-Forwarded-Host {host}
}
}
3. The problem I’m having:
I’m trying to reverse-proxy my subdomain to an API running on my VPS. The domain is already routed through Cloudflare, since I need its edge caching.
Unfortunately, even after a couple of hours fiddling with various random docs and tutorials, installing Go and what not, I can’t get it to work. Visiting the address shows error 502, and the same error shows up in Caddy’s logs.
4. Error messages and/or full log output:
$ sudo caddy run debug
2022/03/11 13:33:38.395 INFO using adjacent Caddyfile
2022/03/11 13:33:38.403 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2022/03/11 13:33:38.404 INFO http server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {"server_name": "srv0", "https_port": 443}
2022/03/11 13:33:38.405 INFO http enabling automatic HTTP->HTTPS redirects {"server_name": "srv0"}
2022/03/11 13:33:38.406 INFO http enabling automatic TLS certificate management {"domains": ["images.genfic.net"]}
2022/03/11 13:33:38.408 INFO autosaved config (load with --resume flag) {"file": "/root/.config/caddy/autosave.json"}
2022/03/11 13:33:38.408 INFO serving initial configuration
2022/03/11 13:33:38.409 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc000572e00"}
2022/03/11 13:33:38.409 INFO tls cleaning storage unit {"description": "FileStorage:/root/.local/share/caddy"}
2022/03/11 13:33:38.411 INFO tls finished cleaning storage units
2022/03/11 13:33:51.757 ERROR http.log.error EOF {"request": {"remote_addr": "141.101.77.227:21808", "proto": "HTTP/2.0", "method": "GET", "host": "images.genfic.net", "uri": "/", "headers": {"Accept-Encoding": ["gzip"], "Cf-Ipcountry": ["FR"], "Cf-Ray": ["6ea4aa0defc097ac-AMS"], "X-Forwarded-Proto": ["https"], "Cf-Connecting-Ip": ["146.59.95.130"], "Cdn-Loop": ["cloudflare"], "X-Forwarded-For": ["146.59.95.130"], "Cf-Visitor": ["{\"scheme\":\"https\"}"], "User-Agent": ["curl/7.64.0"], "Accept": ["*/*"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "proto_mutual": true, "server_name": "images.genfic.net"}}, "duration": 0.012296872, "status": 502, "err_id": "r1a1mk4nm", "err_trace": "reverseproxy.statusError (reverseproxy.go:886)"}
5. What I already tried:
- I tried using Xcaddy instead, but to no avail