I’m using caddy on VPS and trying to do Reverse Proxy with IP Certificates
1. The problem I’m having:
When using reverse_proxy with IP Certificates the browser got Error code: 502 Bad Gateway.
When i use respond directive it works as expected.
2. Error messages and/or full log output:
{
"duration": 0.000341561,
"err_id": "01vcbnzfx",
"err_trace": "reverseproxy.statusError (reverseproxy.go:1390)",
"level": "error",
"logger": "http.log.error",
"msg": "dial tcp 127.0.0.1:8082: connect: connection refused",
"request": {
"client_ip": "(Client-IP Redacted)",
"headers": {
"Accept": [
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
],
"Accept-Encoding": [
"gzip, deflate, br, zstd"
],
"Accept-Language": [
"en-US,en;q=0.9"
],
"Priority": [
"u=0, i"
],
"Sec-Fetch-Dest": [
"document"
],
"Sec-Fetch-Mode": [
"navigate"
],
"Sec-Fetch-Site": [
"none"
],
"Sec-Fetch-User": [
"?1"
],
"Sec-Gpc": [
"1"
],
"Te": [
"trailers"
],
"Upgrade-Insecure-Requests": [
"1"
],
"User-Agent": [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0"
]
},
"host": "(Public-IP Redacted)",
"method": "GET",
"proto": "HTTP/2.0",
"remote_ip": "143.44.144.17",
"remote_port": "2204",
"tls": {
"cipher_suite": 4865,
"proto": "h2",
"resumed": false,
"server_name": "",
"version": 772
},
"uri": "/"
},
"status": 502,
"ts": 1768874322.175636
}
3. Caddy version:
v2.10.2 h1:g/gTYjGMD0dec+UgMw8SnfmJ3I9+M2TdvoRL/Ovu6U8=
4. How I installed and ran Caddy:
Docker Compose
services:
caddy:
image: caddy:latest
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./data/conf:/etc/caddy
- ./data/site:/srv
- ./data/caddy_data:/data
- ./data/caddy_config:/config
it-tools:
container_name: it-tools
restart: unless-stopped
ports:
- 127.0.0.1:8082:80
image: ghcr.io/corentinth/it-tools:latest
a. System environment:
b. Command:
c. Service/unit/compose file:
d. My complete Caddy config:
{
default_sni (Public-IP Redacted)
}
(Public-IP Redacted), :443 {
tls {
issuer acme {
profile shortlived
}
}
# respond "It's working"
reverse_proxy 127.0.0.1:8082
}