1. Output of caddy version
:
2. How I run Caddy:
Caddy is run via docker-compose.
a. System environment:
CentOS, Docker, Docker-Compose
b. Command:
docker-compose up
c. Service/unit/compose file:
caddy:
container_name: caddy
image: 'index.docker.io/caddy:2.5.1-alpine@sha256:6e62b63d4d7a4826f9e93c904a0e5b886a8bea2234b6569e300924282a2e8e6c'
cpus: 4
mem_limit: '4g'
environment:
- 'XDG_DATA_HOME=/caddy-storage/data'
- 'XDG_CONFIG_HOME=/caddy-storage/config'
- 'SRC_FRONTEND_ADDRESSES=service-frontend-0:3080'
- 'SRC_SITE_ADDRESS=192.168.1.10'
- 'SRC_ACME_EMAIL=andy.mccall@myemail.com'
volumes:
- 'caddy:/caddy-storage'
- '/opt/service/caddy/builtins/https.custom-cert.Caddyfile:/etc/caddy/Caddyfile'
- '/opt/service/certs.d/192.168.1.10.cert:/service.pem'
- '/opt/service/certs.d/192.168.1.10.key:/service.key'
ports:
- '0.0.0.0:80:80'
- '0.0.0.0:443:443'
networks:
- service-network
restart: always
d. My complete Caddy config:
:443
@http {
protocol http
}
redir @http https://{host}{uri}
tls /service.pem /service.key
reverse_proxy {
to 192.168.1.10
trusted_proxies 0.0.0.0/0
}
3. The problem I’m having:
This config works find for serving the service out via https terminating the SSL, however, I need to also add some proxying for a path, that being the /metrics path. This should proxy to service2 that is served on port 9100. I’m new to Caddy, and the config that works was created by a vendor, but they won’t support me adding info to their config (I understand why), but it’s still something I need to do.
4. Error messages and/or full log output:
When I use my (poorly) created config file, the caddy service continually restarts in docker.
5. What I already tried:
I’ve tried adding the config in for the /metrics proxying like this:
:443
@http {
protocol http
}
redir @http https://{host}{uri}
tls /service.pem /service.key
reverse_proxy {
to 192.168.1.10
trusted_proxies 0.0.0.0/0
/metrics 192.168.1.10:9100
}