added path to routing

This commit is contained in:
Jakub Dorfman 2026-05-20 01:07:37 +02:00
parent 7fd2531501
commit 85e29b8734
4 changed files with 84 additions and 30 deletions

23
API.md
View file

@ -69,6 +69,20 @@ Default bind: `127.0.0.1:9911`
}
```
### Create app (multiple routes, different ports, with paths)
```json
{
"name": "pocketbase",
"routes": [
{"domain": "pb.srazka.com", "upstream": "127.0.0.1:8090", "path": "/_/*"}
],
"auth": true
}
```
The `path` field is optional. When present, it generates a Caddy `reverse_proxy /_/* 127.0.0.1:8090` rule, letting you route requests to a specific path prefix within a domain.
### Create app (wildcard domain)
```json
@ -89,11 +103,14 @@ Note: Wildcard domains require DNS challenge configuration in Caddy.
{
"routes": [
{"domain": "app.srazka.com", "upstream": "127.0.0.1:18080"},
{"domain": "api.srazka.com", "upstream": "127.0.0.1:18081"}
{"domain": "api.srazka.com", "upstream": "127.0.0.1:18081"},
{"domain": "pb.srazka.com", "upstream": "127.0.0.1:8090", "path": "/_/*"}
]
}
```
The optional `path` field generates a Caddy `reverse_proxy <path> <upstream>` rule for sub-path routing.
Caddy reloads automatically via the systemd path watcher. Containers stay running.
### Save compose
@ -128,11 +145,13 @@ Caddy reloads automatically via the systemd path watcher. Containers stay runnin
"name": "myapp",
"routes": [
{"domain": "app.srazka.com", "upstream": "127.0.0.1:18080"},
{"domain": "api.srazka.com", "upstream": "127.0.0.1:18081"}
{"domain": "api.srazka.com", "upstream": "127.0.0.1:18081", "path": "/api/*"}
]
}
```
The `path` field is only present when a route has a path configured.
## Response format
All JSON responses include an `ok` boolean: