1. The problem I’m having:
←
I am new to caddy. Previously I always used Apache2 as my webserver of choice. I am trying to use caddy as reverse proxy. I am using LXD container with Ubuntu 22.14. have installed node server and caddy successfully. I am using node v22.14. All of this is in an LXD container. When I browse to the container IP (192.168.1.47)
Node: WebTransport server running on https://localhost:4433 When I browse to 192.168.1.47, I get a HTTP/2 502 error? →
→
2. Error messages and/or full log output:
$ journalctl -u caddy --no-pager | less +G
"name":"srv1","protocols":["h1","h2","h3"]}
Mar 02 13:41:33 CaddyWebtransport caddy[1226]: {"level":"info","ts":1740922893.4507356,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["192.168.1.47"]}
Mar 02 13:41:33 CaddyWebtransport caddy[1226]: {"level":"info","ts":1740922893.4749036,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"}
Mar 02 13:41:33 CaddyWebtransport caddy[1226]: {"level":"info","ts":1740922893.4751632,"msg":"serving initial configuration"}
Mar 02 13:41:33 CaddyWebtransport systemd[1]: Started caddy.service - Caddy.
Mar 02 15:14:27 CaddyWebtransport caddy[1226]: {"level":"error","ts":1740928467.7561662,"logger":"http.log.error","msg":"EOF","request":{"remote_ip":"192.168.1.38","remote_port":"58394","client_ip":"192.168.1.38","proto":"HTTP/2.0","method":"GET","host":"192.168.1.47","uri":"/","headers":{"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-User":["?1"],"Te":["trailers"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"],"Accept-Language":["en-US,en;q=0.5"],"Sec-Fetch-Dest":["document"],"Sec-Fetch-Site":["none"],"Priority":["u=0, i"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Upgrade-Insecure-Requests":["1"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":""}},"duration":0.020323073,"status":502,"err_id":"c7df0m7jz","err_trace":"reverseproxy.statusError (reverseproxy.go:1373)"}
Mar 02 15:14:44 CaddyWebtransport caddy[1226]: {"level":"error","ts":1740928484.481648,"logger":"http.log.error","msg":"EOF","request":{"remote_ip":"192.168.1.38","remote_port":"58394","client_ip":"192.168.1.38","proto":"HTTP/2.0","method":"GET","host":"192.168.1.47","uri":"/","headers":{"Sec-Fetch-Dest":["document"],"Accept-Language":["en-US,en;q=0.5"],"Sec-Fetch-User":["?1"],"Sec-Fetch-Site":["none"],"Te":["trailers"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Upgrade-Insecure-Requests":["1"],"Sec-Fetch-Mode":["navigate"],"Priority":["u=0, i"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":""}},"duration":0.002250698,"status":502,"err_id":"4x5bhjk8g","err_trace":"reverseproxy.statusError (reverseproxy.go:1373)"}
3. Caddy version: v2.9.1 h1:OEYiZ7DbCzAWVb6TNEkjRcSCRGHVoZsJinoDR/n9oaY=
4. How I installed and ran Caddy:
←
sudo apt update
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -fsSL https://dl.cloudsmith.io/public/caddy/stable/gpg.key | sudo tee /usr/share/keyrings/caddy-keyring.asc >/dev/null
echo "deb [signed-by=/usr/share/keyrings/caddy-keyring.asc] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" | sudo tee /etc/apt/sources.list.d/caddy.list
sudo apt update
sudo apt install -y caddy
sudo systemctl start caddy
→
a. System environment:
b. Command: sudo systemctl start caddy
### c. Service/unit/compose file:
### d. My complete Caddy config:
<!--
vboxuser@CaddyWebtransport:/etc/caddy$ caddy fmt
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
:80 {
# Set this path to your site’s directory.
root * /usr/share/caddy
# Enable the static file server.
file_server
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}
Remove the servers block and the experimental_http3 option completely,
as Caddy 2 automatically supports HTTP/3 when using https.
localhost {
reverse_proxy localhost:4433
# tls internal # Optional: Use self-signed cert if you don’t have a domain
}
Refer to the Caddy docs for more information:
The Caddyfile — Caddy Documentation
→
### 5. Links to relevant resources:
<!-- Optional, but can help get us on the same page quickly. -->