1. Caddy version (caddy version
):
v2.4.6
2. How I run Caddy:
a. System environment:
On Ubuntu LXC hosted on my Proxmox VE
b. Command:
Paste command here.
c. Service/unit/compose file:
I dont know where to find this file , Sorry , i am new to the CADDY world.
d. My complete Caddyfile or JSON config:
its empty as I am using api only to configure Caddy
3. The problem I’m having:
I am trying to automate adding multiple reverse proxy host to help me host multiple dynamic servers on my Proxmox VE.
For eg, I made a php web app that i can log on to and create virtual machines by giving them a hostname (that is already forwarded to my caddy server) and after the script is done creating the virtual machine it will via the api add that hostname to my caddy to begin reverse proxying that hostname to that virtual machine to make it accessible from the internet.
I can able to add just one reverse proxy server via api using the following curl :
curl 172.16.199.119:2020/load \
-X POST \
-H "Content-Type: application/json" \
-d @- << EOF
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"testing.abc.de"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "192.168.88.20:80"
}
]
}
]
}
]
}
],
"terminal": true
}
]
}
}
}
}
}
EOF
Here is the real problem :
If a change the IP and hostname in the above curl request, the old one gets replaced, and I know because of the POST method .
I have read on the api docs that i can update certain parts of the config using PUT method but don’t know how !
This is where I need help
Please can i get the exact curl to add and remove another host like test.abc.xyz and reverse proxy it to 192.168.88.20:80 without removing the previous entries.
I am trying to read the docs and unable to understand how to make it work.
4. Error messages and/or full log output:
5. What I already tried:
I have tried the following :
curl 172.16.199.119:2020/config/apps \
-X PUT \
-H "Content-Type: application/json" \
-d @- << EOF
{
"http": {
"servers": {
"srv0": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"test.abc.xyz "
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "192.168.88.20:80"
}
]
}
]
}
]
}
],
"terminal": true
}
]
}
}
}
}
EOF
And i get the this error :
{"error":"[/config/apps] key already exists: apps"}