added support for multiple routes multiple ports

This commit is contained in:
Jakub Dorfman 2026-05-20 00:21:25 +02:00
parent 7399cf83f9
commit 7fd2531501
4 changed files with 445 additions and 151 deletions

59
API.md
View file

@ -19,6 +19,7 @@ Default bind: `127.0.0.1:9911`
|--------|------|-------------|
| GET | `/apps` | List all apps |
| GET | `/apps/<name>` | Show single app manifest |
| GET | `/apps/<name>/routes` | Get parsed route entries |
| GET | `/apps/<name>/status` | Container status (running/stopped) |
| GET | `/apps/<name>/compose` | Read compose.yaml content |
| GET | `/apps/<name>/logs?tail=N` | Fetch last N log lines (default 100) |
@ -30,6 +31,7 @@ Default bind: `127.0.0.1:9911`
| Method | Path | Description |
|--------|------|-------------|
| POST | `/apps/init` | Create a new app |
| POST | `/apps/<name>/routes` | Update routes (hot — Caddy reloads automatically) |
| POST | `/apps/<name>/deploy` | Deploy (compose up + caddy reload) |
| POST | `/apps/<name>/restart` | Restart (compose down + up) |
| POST | `/apps/<name>/stop` | Stop (compose down) |
@ -42,35 +44,27 @@ Default bind: `127.0.0.1:9911`
## Example payloads
### Create app (single domain)
### Create app (single route)
```json
{
"name": "whoami",
"domain": "whoami.srazka.com",
"port": 18080,
"routes": [
{"domain": "whoami.srazka.com", "upstream": "127.0.0.1:18080"}
],
"auth": true
}
```
### Create app (multiple domains)
### Create app (multiple routes, different ports)
```json
{
"name": "myapp",
"domain": "app.srazka.com,www.app.srazka.com",
"port": 18081,
"auth": true
}
```
Or using the `domains` array format:
```json
{
"name": "myapp",
"domains": ["app.srazka.com", "www.app.srazka.com"],
"port": 18081,
"routes": [
{"domain": "app.srazka.com", "upstream": "127.0.0.1:18080"},
{"domain": "api.app.srazka.com", "upstream": "127.0.0.1:18081"}
],
"auth": true
}
```
@ -80,14 +74,28 @@ Or using the `domains` array format:
```json
{
"name": "wildcard",
"domain": "*.srazka.com",
"port": 18082,
"routes": [
{"domain": "*.srazka.com", "upstream": "127.0.0.1:18082"}
],
"auth": false
}
```
Note: Wildcard domains require DNS challenge configuration in Caddy.
### Update routes (hot)
```json
{
"routes": [
{"domain": "app.srazka.com", "upstream": "127.0.0.1:18080"},
{"domain": "api.srazka.com", "upstream": "127.0.0.1:18081"}
]
}
```
Caddy reloads automatically via the systemd path watcher. Containers stay running.
### Save compose
```json
@ -112,6 +120,19 @@ Note: Wildcard domains require DNS challenge configuration in Caddy.
}
```
## Routes response
```json
{
"ok": true,
"name": "myapp",
"routes": [
{"domain": "app.srazka.com", "upstream": "127.0.0.1:18080"},
{"domain": "api.srazka.com", "upstream": "127.0.0.1:18081"}
]
}
```
## Response format
All JSON responses include an `ok` boolean: