fix
This commit is contained in:
parent
c08b7c1f63
commit
a1942c0054
2 changed files with 8 additions and 2 deletions
|
|
@ -56,7 +56,7 @@ On project creation, when Caddy routing is enabled, the app appends a route to:
|
||||||
Route shape:
|
Route shape:
|
||||||
- `match.host = [<project host>]`
|
- `match.host = [<project host>]`
|
||||||
- `handle[0].handler = reverse_proxy`
|
- `handle[0].handler = reverse_proxy`
|
||||||
- `handle[0].upstreams[0].dial = 127.0.0.1:<target_port>`
|
- `handle[0].upstreams[0].dial = unix/<unix-user-home>/projects/<app>/app.sock`
|
||||||
|
|
||||||
## Workspaces and Unix Users
|
## Workspaces and Unix Users
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -56,10 +57,15 @@ func (a *App) ensureCaddyRoute(ctx context.Context, p Project) error {
|
||||||
if !a.cfg.CaddyRouteEnabled {
|
if !a.cfg.CaddyRouteEnabled {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
projectDir, err := a.projectDirFor(p)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
socketPath := filepath.Join(projectDir, "app.sock")
|
||||||
route := map[string]any{
|
route := map[string]any{
|
||||||
"@id": "project-route-" + p.UserID + "-" + p.Slug,
|
"@id": "project-route-" + p.UserID + "-" + p.Slug,
|
||||||
"match": []any{map[string]any{"host": []string{p.RouteHost}}},
|
"match": []any{map[string]any{"host": []string{p.RouteHost}}},
|
||||||
"handle": []any{map[string]any{"handler": "reverse_proxy", "upstreams": []any{map[string]any{"dial": fmt.Sprintf("127.0.0.1:%d", p.TargetPort)}}}},
|
"handle": []any{map[string]any{"handler": "reverse_proxy", "upstreams": []any{map[string]any{"dial": "unix/" + socketPath}}}},
|
||||||
}
|
}
|
||||||
body, _ := json.Marshal(route)
|
body, _ := json.Marshal(route)
|
||||||
url := fmt.Sprintf("%s/config/apps/http/servers/%s/routes", a.cfg.CaddyAdminURL, a.cfg.CaddyServerID)
|
url := fmt.Sprintf("%s/config/apps/http/servers/%s/routes", a.cfg.CaddyAdminURL, a.cfg.CaddyServerID)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue