1. Caddy version (caddy version
):
v2.2.1 h1:Q62GWHMtztnvyRU+KPOpw6fNfeCD3SkwH7SfT1Tgt2c=
2. How I run Caddy:
a. System environment:
Docker version 19.03.11, build 42e35e61f3
docker-compose version 1.17.1, build unknown
b. Command:
sudo docker-compose -f docker-compose-base.yml up
c. Service/unit/compose file:
Dockerfile:
FROM caddy:2-builder AS builder
RUN xcaddy build \
--with github.com/caddy-dns/route53
FROM caddy:2
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
Docker compose file:
version: "3"
services:
node:
image: "node:12"
working_dir: /home/node/app
volumes:
- ./:/home/node/app
command: "node serv.js"
caddy:
env_file:
- .env
build: .
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
volumes:
caddy_data:
caddy_config:
d. My complete Caddyfile or JSON config:
{
email email@example.com
}
*.{$WILDCARD_DOMAIN} {
tls {
dns route53 {
max_retries 10
}
}
reverse_proxy {$ELB_HOST} {
header_up +codomain {host}
}
reverse_proxy /app* {$ELB_HOST} {
header_up +codomain {host}
header_up +service admin-ui
}
reverse_proxy /embed* {$ELB_HOST} {
header_up +codomain {host} # TODO: remove codomain since host gets passed through
header_up +service embed
}
uri /app/_next* strip_prefix /app
uri /app/static* strip_prefix /app
log {
output stdout
}
}
3. The problem I’m having:
For this request https://app.{$WILDCARD_DOMAIN}.com/app/_next/static/runtime/main-87b364dedc78de6f0c78.js
no service
header get set.
I expect service
header to be set to admin-ui
for the backend server.
4. Error messages and/or full log output:
These are headers I received in my node app:
{
host: 'app.{$WILDCARD_DOMAIN}.com',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:84.0) Gecko/20100101 Firefox/84.0',
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.5',
'cache-control': 'max-age=0',
codomain: 'app.{$WILDCARD_DOMAIN}.com',
cookie: 'REDACTED',
te: 'trailers',
'upgrade-insecure-requests': '1',
'x-forwarded-for': 'REDACTED IP',
'x-forwarded-proto': 'https'
}
5. What I already tried:
It appears it’s matching reverse_proxy
with the implicit wildcard due to the uri
directive because when I comment out the following, it doesn’t even send traffic to the backend:
reverse_proxy {$ELB_HOST} {
header_up +codomain {host}
}
I’m not sure how to get around that.