1. The problem I’m having:
I’m trying to use caddy in docker to serve a website and use reverse proxy for an API.
In our environment we also use Consul.
The problem I’m having is that the service is being registered against consul with the port suffix (my-frontend-80 instead of my-frontend. I believe this is because the docker container is listening on more than one port.
Is it possible to prevent the caddy container from listening on additional ports?
Example from docker inspect:
"Ports": {
"2019/tcp": null,
"443/tcp": null,
"443/udp": null,
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
}
]
},
This includes using the global caddy options:
{
admin off
auto_https off
}
2. Error messages and/or full log output:
3. Caddy version:
2.7.6
4. How I installed and ran Caddy:
a. System environment:
Docker
b. Command:
docker run --rm --name my-frontend -p 8080:80 my-frontend:latest
c. Service/unit/compose file:
FROM caddy:2.7.6
WORKDIR /app
COPY ./caddy/Caddyfile /etc/caddy/Caddyfile
COPY ./dist/my-frontend/browser /usr/share/caddy
d. My complete Caddy config:
{
admin off
auto_https off
}
http://localhost:80 {
encode gzip
handle /api/* {
uri strip_prefix /api
reverse_proxy http://my-service.path.here:80
}
handle {
root * /usr/share/caddy
try_files {path} /index.html
file_server
}
}