How to create a new array with API

1. The problem I’m having:

I am not able to add new entries for wild card subdomains

curl localhost:2019/config/apps/http/servers/srv0/routes/2/handle/0/routes/10/group -H “Content-Type: application/json” -d ‘“group18”’

{“error”:“[/config/apps/http/servers/srv0/routes/2/handle/0/routes/10] array index out of bounds: 10”}

curl -X PUT -H “Content-Type: application/json” -d ‘“group18”’ “localhost:2019/config/apps/http/servers/srv0/routes/2/handle/0/routes/10/group”{“error”:“[/config/apps/http/servers/srv0/routes/2/handle/0/routes/10] array index out of bounds: 10”}

2. Error messages and/or full log output:

curl -X PUT -H “Content-Type: application/json” -d ‘“group18”’ “localhost:2019/config/apps/http/servers/srv0/routes/2/handle/0/routes/10/group”{“error”:“[/config/apps/http/servers/srv0/routes/2/handle/0/routes/10] array index out of bounds: 10”}

3. Caddy version:

caddy version

v2.7.6

4. How I installed and ran Caddy:

apt install caddy

a. System environment:

Debian 10

b. Command:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

c. Service/unit/compose file:

Its original systemd, no modifications

5. Links to relevant resources:

Nothing is helpful from below links

Are you sure 10 is correct? How many entries are already in the array? Indexes start at zero. Try 9 instead maybe?

You might be better off fetching that config value, making a modification locally, then using PATCH to replace it. That way you’re not dependent on current indices on the server.

You can use Etag + If-Match to ensure the config hasn’t changed in between fetching the value and pushing it.

1 Like

There are 9 entries already. I didt understand what do you mean by PATCH

I want to add all the details below

  1. To add a new wild card subdomain

  2. To add remote_ip to limit access

  3. To Reverse_proxy

  4. And to add logging

    log {
    hostnames test1.com
    output file /var/log/caddy/test1.com.log
    }
    @test {
    host test1.com
    remote_ip 1.1.1.1
    }
    handle @test {
    reverse_proxy localhost:11003
    }

If there’s 9 entries, then you need to insert at index 9. Because it’s 0-indexed. So it goes: 0,1,2,3,4,5,6,7,8 and that’s a count of 9 entries. So to add one more (a 10th entry), its index would be 9. Not 10.

PATCH is an HTTP method: API — Caddy Documentation

You can write a Caddyfile that does those things, then use the caddy adapt -p command to see what it looks like as JSON config. That’s the easiest way to learn JSON config.

Why are you using the API, exactly? You could likely do what you want with a Caddyfile instead. But it depends.

I mean, I get values when I fetch with 9, so tried adding to 10.
I need an API, so that I need to add it to my software to automatically add them. I need to add atleast 5 entries a day.

Also can we add them in a single API command?
log {
hostnames test1.com
output file /var/log/caddy/test1.com.log
}
@test {
host test1.com
remote_ip 1.1.1.1
}
handle @test {
reverse_proxy localhost:11003
}

curl -X PUT -H “Content-Type: application/json” -d ‘“group18”’ “localhost:2019/config/apps/http/servers/srv0/routes/2/handle/0/routes/9/group”
{“error”:“[/config/apps/http/servers/srv0/routes/2/handle/0/routes/9/group] key already exists: group”}

If you could please post your starting JSON config in its entirety, then the API request that doesn’t work as you expect, I will see if we can help you.

{
    "logging": {
        "logs": {
            "default": {
                "exclude": [
                    "http.log.access.log0",
                    "http.log.access.log1",
                    "http.log.access.log2",
                    "http.log.access.log3"
                ]
            },
            "log0": {
                "writer": {
                    "filename": "/var/log/caddy/demo.app.test.com.log",
                    "output": "file"
                },
                "include": [
                    "http.log.access.log0"
                ]
            },
            "log1": {
                "writer": {
                    "filename": "/var/log/caddy/demo1.app.test.com.log",
                    "output": "file"
                },
                "include": [
                    "http.log.access.log1"
                ]
            },
            "log2": {
                "writer": {
                    "filename": "/var/log/caddy/www.app.test.com.log",
                    "output": "file"
                },
                "include": [
                    "http.log.access.log2"
                ]
            },
            "log3": {
                "writer": {
                    "filename": "/var/log/caddy/app.test.com.log",
                    "output": "file"
                },
                "include": [
                    "http.log.access.log3"
                ]
            }
        }
    },
    "apps": {
        "http": {
            "servers": {
                "srv0": {
                    "listen": [
                        ":443"
                    ],
                    "routes": [
                        {
                            "match": [
                                {
                                    "host": [
                                        "*.app.test.com"
                                    ]
                                }
                            ],
                            "handle": [
                                {
                                    "handler": "subroute",
                                    "routes": [
                                        {
                                            "handle": [
                                                {
                                                    "handler": "static_response",
                                                    "headers": {
                                                        "Location": [
                                                            "/test"
                                                        ]
                                                    },
                                                    "status_code": 302
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "path": [
                                                        "/"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group9",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "abort": true,
                                                                    "handler": "static_response"
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "path": [
                                                        "/test/actuator/*"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group9",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "vars",
                                                                    "root": "/var/www/html"
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "group": "group0",
                                                            "handle": [
                                                                {
                                                                    "handler": "rewrite",
                                                                    "uri": "/var/www/html/robots.txt"
                                                                }
                                                            ],
                                                            "match": [
                                                                {
                                                                    "path": [
                                                                        "/robots.txt"
                                                                    ]
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "file_server",
                                                                    "hide": [
                                                                        "./Caddyfile1"
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "path": [
                                                        "/robots.txt"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group9",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "abort": true,
                                                                    "handler": "static_response"
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "path": [
                                                        "/health"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group9",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "reverse_proxy",
                                                                    "upstreams": [
                                                                        {
                                                                            "dial": "0.0.0.0:11001"
                                                                        }
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "host": [
                                                        "demo.app.test.com"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group9",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "reverse_proxy",
                                                                    "upstreams": [
                                                                        {
                                                                            "dial": "0.0.0.0:11002"
                                                                        }
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "host": [
                                                        "demo1.app.test.com"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group9",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "vars",
                                                                    "root": "/var/www/html"
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "group": "group5",
                                                            "handle": [
                                                                {
                                                                    "handler": "rewrite",
                                                                    "uri": "www.html"
                                                                }
                                                            ],
                                                            "match": [
                                                                {
                                                                    "path": [
                                                                        "/test"
                                                                    ]
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "file_server",
                                                                    "hide": [
                                                                        "./Caddyfile1"
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "host": [
                                                        "www.app.test.com"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group9",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "vars",
                                                                    "root": "/var/www/html"
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "group": "group6",
                                                            "handle": [
                                                                {
                                                                    "handler": "rewrite",
                                                                    "uri": "www.html"
                                                                }
                                                            ],
                                                            "match": [
                                                                {
                                                                    "path": [
                                                                        "/test"
                                                                    ]
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "file_server",
                                                                    "hide": [
                                                                        "./Caddyfile1"
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "host": [
                                                        "app.test.com"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group9",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "static_response",
                                                                    "headers": {
                                                                        "Location": [
                                                                            "https://www.app.test.com"
                                                                        ]
                                                                    },
                                                                    "status_code": 302
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ],
                            "terminal": true
                        }
                    ],
                    "errors": {
                        "routes": [
                            {
                                "match": [
                                    {
                                        "host": [
                                            "*.app.test.com"
                                        ]
                                    }
                                ],
                                "handle": [
                                    {
                                        "handler": "subroute",
                                        "routes": [
                                            {
                                                "handle": [
                                                    {
                                                        "handler": "vars",
                                                        "root": "/var/www/html"
                                                    }
                                                ]
                                            },
                                            {
                                                "group": "group8",
                                                "handle": [
                                                    {
                                                        "handler": "rewrite",
                                                        "uri": "maintenance.html"
                                                    }
                                                ],
                                                "match": [
                                                    {
                                                        "expression": "{http.error.status_code} == 502"
                                                    }
                                                ]
                                            },
                                            {
                                                "handle": [
                                                    {
                                                        "handler": "file_server",
                                                        "hide": [
                                                            "./Caddyfile1"
                                                        ]
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ],
                                "terminal": true
                            }
                        ]
                    },
                    "tls_connection_policies": [
                        {
                            "match": {
                                "sni": [
                                    "*.app.test.com"
                                ]
                            },
                            "certificate_selection": {
                                "any_tag": [
                                    "cert0"
                                ]
                            }
                        },
                        {}
                    ],
                    "logs": {
                        "logger_names": {
                            "app.test.com": "log3",
                            "demo.app.test.com": "log0",
                            "demo1.app.test.com": "log1",
                            "www.app.test.com": "log2"
                        }
                    }
                }
            }
        },
        "tls": {
            "certificates": {
                "load_files": [
                    {
                        "certificate": "/etc/letsencrypt/live/app.test.com/fullchain.pem",
                        "key": "/etc/letsencrypt/live/app.test.com/privkey.pem",
                        "tags": [
                            "cert0"
                        ]
                    }
                ]
            }
        }
    }
}

This is my caddy.json
I want to add a subdomain demo2.app.test.com with the following parameters. How can I achieve it via API?

log {
	hostnames demo2.app.test.com
	output file /var/log/caddy/demo2.app.test.com.log
}
@demo2 host demo2.app.test.com
handle @demo2 {
	reverse_proxy 0.0.0.0:11003
}

Make a Caddyfile with just those contents, then adapt it to JSON with caddy adapt -p. You’ll see what that produces. Then you need to turn those bits into individual curl modifications to insert them into your original config.

For example, you’ll need to insert a new logger, maybe named log4, then insert a new route inside /apps/http/servers/srv0/routes/0/handle/0/routes with your host matcher + subroute with proxy, then add to logger_names a mapping of your new domain to the logger you added log4.

Or, with whatever scripting language of your choice, download the current config, manipulate the current config as needed, then push the whole thing back to Caddy, so that it’s just a single reload instead of multiple in a row.

The problem here is I have frequent requests to add subdomains and need to integrate with my app to automate the process.

For example, you’ll need to insert a new logger, maybe named `log4`, then insert a new route inside `/apps/http/servers/srv0/routes/0/handle/0/routes` with your host matcher + subroute with proxy, then add to `logger_names` a mapping of your new domain to the logger you added `log4`.

Can you give the exact curl commands for inserting the following, which will be helpful as I dont have much idea on this.

log {
	hostnames demo2.app.test.com
	output file /var/log/caddy/demo2.app.test.com.log
}
@demo2 host demo2.app.test.com
handle @demo2 {
	reverse_proxy 0.0.0.0:11003
}

json file including these entries:

{
    "logging": {
        "logs": {
            "default": {
                "exclude": [
                    "http.log.access.log0",
                    "http.log.access.log1",
                    "http.log.access.log2",
                    "http.log.access.log3",
                    "http.log.access.log4"
                ]
            },
            "log0": {
                "writer": {
                    "filename": "/var/log/caddy/demo.app.test.com.log",
                    "output": "file"
                },
                "include": [
                    "http.log.access.log0"
                ]
            },
            "log1": {
                "writer": {
                    "filename": "/var/log/caddy/demo1.app.test.com.log",
                    "output": "file"
                },
                "include": [
                    "http.log.access.log1"
                ]
            },
            "log2": {
                "writer": {
                    "filename": "/var/log/caddy/demo2.app.test.com.log",
                    "output": "file"
                },
                "include": [
                    "http.log.access.log2"
                ]
            },
            "log3": {
                "writer": {
                    "filename": "/var/log/caddy/www.app.test.com.log",
                    "output": "file"
                },
                "include": [
                    "http.log.access.log3"
                ]
            },
            "log4": {
                "writer": {
                    "filename": "/var/log/caddy/app.test.com.log",
                    "output": "file"
                },
                "include": [
                    "http.log.access.log4"
                ]
            }
        }
    },
    "apps": {
        "http": {
            "servers": {
                "srv0": {
                    "listen": [
                        ":443"
                    ],
                    "routes": [
                        {
                            "match": [
                                {
                                    "host": [
                                        "*.app.test.com"
                                    ]
                                }
                            ],
                            "handle": [
                                {
                                    "handler": "subroute",
                                    "routes": [
                                        {
                                            "handle": [
                                                {
                                                    "handler": "static_response",
                                                    "headers": {
                                                        "Location": [
                                                            "/test"
                                                        ]
                                                    },
                                                    "status_code": 302
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "path": [
                                                        "/"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group10",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "abort": true,
                                                                    "handler": "static_response"
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "path": [
                                                        "/test/actuator/*"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group10",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "vars",
                                                                    "root": "/var/www/html"
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "group": "group0",
                                                            "handle": [
                                                                {
                                                                    "handler": "rewrite",
                                                                    "uri": "/var/www/html/robots.txt"
                                                                }
                                                            ],
                                                            "match": [
                                                                {
                                                                    "path": [
                                                                        "/robots.txt"
                                                                    ]
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "file_server",
                                                                    "hide": [
                                                                        "./Caddyfile"
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "path": [
                                                        "/robots.txt"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group10",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "abort": true,
                                                                    "handler": "static_response"
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "path": [
                                                        "/health"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group10",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "reverse_proxy",
                                                                    "upstreams": [
                                                                        {
                                                                            "dial": "0.0.0.0:11001"
                                                                        }
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "host": [
                                                        "demo.app.test.com"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group10",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "reverse_proxy",
                                                                    "upstreams": [
                                                                        {
                                                                            "dial": "0.0.0.0:11002"
                                                                        }
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "host": [
                                                        "demo1.app.test.com"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group10",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "reverse_proxy",
                                                                    "upstreams": [
                                                                        {
                                                                            "dial": "0.0.0.0:11003"
                                                                        }
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "host": [
                                                        "demo2.app.test.com"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group10",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "vars",
                                                                    "root": "/var/www/html"
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "group": "group6",
                                                            "handle": [
                                                                {
                                                                    "handler": "rewrite",
                                                                    "uri": "www.html"
                                                                }
                                                            ],
                                                            "match": [
                                                                {
                                                                    "path": [
                                                                        "/test"
                                                                    ]
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "file_server",
                                                                    "hide": [
                                                                        "./Caddyfile"
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "host": [
                                                        "www.app.test.com"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group10",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "vars",
                                                                    "root": "/var/www/html"
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "group": "group7",
                                                            "handle": [
                                                                {
                                                                    "handler": "rewrite",
                                                                    "uri": "www.html"
                                                                }
                                                            ],
                                                            "match": [
                                                                {
                                                                    "path": [
                                                                        "/test"
                                                                    ]
                                                                }
                                                            ]
                                                        },
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "file_server",
                                                                    "hide": [
                                                                        "./Caddyfile"
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "host": [
                                                        "app.test.com"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group10",
                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "static_response",
                                                                    "headers": {
                                                                        "Location": [
                                                                            "https://www.app.test.com"
                                                                        ]
                                                                    },
                                                                    "status_code": 302
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ],
                            "terminal": true
                        }
                    ],
                    "errors": {
                        "routes": [
                            {
                                "match": [
                                    {
                                        "host": [
                                            "*.app.test.com"
                                        ]
                                    }
                                ],
                                "handle": [
                                    {
                                        "handler": "subroute",
                                        "routes": [
                                            {
                                                "handle": [
                                                    {
                                                        "handler": "vars",
                                                        "root": "/var/www/html"
                                                    }
                                                ]
                                            },
                                            {
                                                "group": "group9",
                                                "handle": [
                                                    {
                                                        "handler": "rewrite",
                                                        "uri": "maintenance.html"
                                                    }
                                                ],
                                                "match": [
                                                    {
                                                        "expression": "{http.error.status_code} == 502"
                                                    }
                                                ]
                                            },
                                            {
                                                "handle": [
                                                    {
                                                        "handler": "file_server",
                                                        "hide": [
                                                            "./Caddyfile"
                                                        ]
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ],
                                "terminal": true
                            }
                        ]
                    },
                    "tls_connection_policies": [
                        {
                            "match": {
                                "sni": [
                                    "*.app.test.com"
                                ]
                            },
                            "certificate_selection": {
                                "any_tag": [
                                    "cert0"
                                ]
                            }
                        },
                        {}
                    ],
                    "logs": {
                        "logger_names": {
                            "app.test.com": "log4",
                            "demo.app.test.com": "log0",
                            "demo1.app.test.com": "log1",
                            "demo2.app.test.com": "log2",
                            "www.app.test.com": "log3"
                        }
                    }
                }
            }
        },
        "tls": {
            "certificates": {
                "load_files": [
                    {
                        "certificate": "/etc/letsencrypt/live/app.test.com/fullchain.pem",
                        "key": "/etc/letsencrypt/live/app.test.com/privkey.pem",
                        "tags": [
                            "cert0"
                        ]
                    }
                ]
            }
        }
    }
}

@francislavoie Can I have an update here ?

This command and its error output doesn’t line up with the config you posted – as there is no …/routes/2/… – there’s only 1 route in srv0.

Please post the config associated with the question you’re asking so that we can help you.

Existing sub domain entry looks like this:

curl localhost:2019/config/apps/http/servers/srv0/routes/0/handle/0/routes/4/

{
    "group": "group8",
    "handle": [
        {
            "handler": "subroute",
            "routes": [
                {
                    "handle": [
                        {
                            "handler": "reverse_proxy",
                            "upstreams": [
                                {
                                    "dial": "0.0.0.0:11002"
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ],
    "match": [
        {
            "host": [
                "demo1.app.test.com"
            ]
        }
    ]
}

New subdomain json should like this. Can you provide the exact curl commands to insert these to json ?

                                            "handle": [
                                                {
                                                    "handler": "subroute",
                                                    "routes": [
                                                        {
                                                            "handle": [
                                                                {
                                                                    "handler": "reverse_proxy",
                                                                    "upstreams": [
                                                                        {
                                                                            "dial": "0.0.0.0:11003"
                                                                        }
                                                                    ]
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            ],
                                            "match": [
                                                {
                                                    "host": [
                                                        "demo2.app.test.com"
                                                    ]
                                                }
                                            ]
                                        },
                                        {
                                            "group": "group8",

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.