1 The problem I’m having:
Please note that the API is currently exposed to everyone because I’m still testing things. The container running caddy will be turned off when not used, so if you try and make requests to it and it doesn’t work, that’s why
I am trying to use the API to create a reverse proxy to proxy requests to web-01.sites.serversnow.co
to 154.26.155.103:3006
. I know it would be easier to use the Caddyfile to create the proxy, but eventually, this will be proxying thousands of different domains (If caddy is capable ) with changes being made frequently.
Unable to save my configuration using the Rest API. My configuration also doesn’t work LOL
I’m using Docker on an Ubuntu 20.04 Server with the following docker-compose file:
services:
caddy:
image: caddy:latest
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
- "2019:2019"
volumes:
- caddy_data:/data
- caddy_config:/config
environment:
- CADDY_ADMIN=0.0.0.0:2019
volumes:
caddy_data:
caddy_config:
The configuration Im trying to use for the API, requesting to 154.26.155.103:2019/config
{
"apps": {
"http": {
"servers": {
"srv1": {
"listen": [":80"],
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "154.26.155.103:3006"
}
]
}
],
"match": [
{
"host": ["web-01.sites.serversnow.co"]
}
]
}
]
}
}
}
}
}
using the cli’s caddy reverse-proxy --from web-01.sites.serversnow.co --to 154.26.155.103:3006
works fine, but it also doesn’t save and once I close the docker exec -ti root-caddy-1 sh
it’s back to not working.
I presume my issue with the saving is related to my docker-compose file’s volumes, but the documentation and guides are a nightmare so
Also the API documentation is even harder to follow to a (brain exploding) level
2. Error messages and/or full log output:
I receive no errors from the API, No errors from the browser (apart from "This site can’t be reached")
3. Caddy version:
v2.6.4 (latest available docker image)
4. How I installed and ran Caddy:
docker compose file and docker compose up -d
a. System environment:
Ubuntu 20.04 Running Docker 24.0.2
Running API requests through Postman v10.15 (latest)
b. Command:
None, I want to use the API
c. Service/unit/compose file:
services:
caddy:
image: caddy:latest
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
- "2019:2019"
volumes:
- caddy_data:/data
- caddy_config:/config
environment:
- CADDY_ADMIN=0.0.0.0:2019
volumes:
caddy_data:
caddy_config:
d. My complete Caddy config:
I don't think I have one, my goal was to solely use the API because it will be frequently updated with different domains