@nocobase/plugin-ai 2.1.0-beta.46 → 2.1.0-beta.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/docs/nocobase/api/cli/app/restart.md +1 -3
- package/dist/ai/docs/nocobase/api/cli/app/start.md +1 -7
- package/dist/ai/docs/nocobase/api/cli/config/delete.md +7 -5
- package/dist/ai/docs/nocobase/api/cli/config/get.md +7 -5
- package/dist/ai/docs/nocobase/api/cli/config/index.md +38 -18
- package/dist/ai/docs/nocobase/api/cli/config/set.md +9 -7
- package/dist/ai/docs/nocobase/api/cli/env/index.md +19 -20
- package/dist/ai/docs/nocobase/api/cli/env/update.md +72 -72
- package/dist/ai/docs/nocobase/api/cli/index.md +0 -1
- package/dist/ai/docs/nocobase/api/cli/init.md +30 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/caddy/current.md +33 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/caddy/generate.md +54 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/caddy/index.md +60 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/caddy/info.md +42 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/caddy/reload.md +32 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/caddy/restart.md +32 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/caddy/start.md +32 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/caddy/status.md +36 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/caddy/stop.md +32 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/caddy/use.md +38 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/index.md +124 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/nginx/current.md +33 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/nginx/generate.md +62 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/nginx/index.md +60 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/nginx/info.md +43 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/nginx/reload.md +32 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/nginx/restart.md +32 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/nginx/start.md +32 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/nginx/status.md +36 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/nginx/stop.md +32 -0
- package/dist/ai/docs/nocobase/api/cli/proxy/nginx/use.md +38 -0
- package/dist/ai/docs/nocobase/data-sources/data-source-external-nocobase/index.md +157 -0
- package/dist/ai/docs/nocobase/data-sources/data-source-manager/index.md +5 -0
- package/dist/ai/docs/nocobase/ops-management/version-control/index.md +79 -0
- package/dist/ai/docs/nocobase/plugins/@nocobase/plugin-version-control/index.md +14 -0
- package/dist/ai/docs/nocobase/quickstart/production/index.md +75 -69
- package/dist/ai/docs/nocobase/quickstart/production/reverse-proxy/caddy.md +211 -80
- package/dist/ai/docs/nocobase/quickstart/production/reverse-proxy/index.md +72 -53
- package/dist/ai/docs/nocobase/quickstart/production/reverse-proxy/nginx.md +186 -89
- package/dist/client/{290.0888139e33c9b7cb.js → 290.0f7f441d8a94f03c.js} +1 -1
- package/dist/client/{428.431a00d29107058e.js → 428.fdd0cc3cfd1632ef.js} +1 -1
- package/dist/client/ai-employees/chatbox/hooks/useChat.d.ts +14 -14
- package/dist/client/ai-employees/chatbox/stores/chat-box.d.ts +1 -105
- package/dist/client/ai-employees/chatbox/stores/chat-conversations.d.ts +1 -37
- package/dist/client/ai-employees/chatbox/stores/chat-messages.d.ts +1 -109
- package/dist/client/index.js +3 -3
- package/dist/client-v2/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +17 -0
- package/dist/client-v2/ai-employees/chatbox/stores/chat-box.d.ts +113 -0
- package/dist/client-v2/ai-employees/chatbox/stores/chat-conversations.d.ts +45 -0
- package/dist/client-v2/ai-employees/chatbox/stores/chat-messages.d.ts +118 -0
- package/dist/client-v2/ai-employees/chatbox/stores/create-selectors.d.ts +18 -0
- package/dist/client-v2/ai-employees/chatbox/stores/global-store.d.ts +9 -0
- package/dist/client-v2/ai-employees/types.d.ts +151 -0
- package/dist/client-v2/index.d.ts +8 -1
- package/dist/client-v2/index.js +1 -1
- package/dist/client-v2/repositories/AIConfigRepository.d.ts +81 -0
- package/dist/client-v2/repositories/hooks/useAIConfigRepository.d.ts +10 -0
- package/dist/collections/ai-context-datasource.js +1 -0
- package/dist/externalVersion.js +16 -16
- package/dist/node_modules/@langchain/xai/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/jsonrepair/package.json +1 -1
- package/dist/node_modules/just-bash/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/collections/ai-conversations.js +1 -0
- package/dist/server/collections/ai-employees.js +1 -0
- package/dist/server/collections/ai-files.js +1 -0
- package/dist/server/collections/ai-messages.js +1 -0
- package/dist/server/collections/ai-settings.js +1 -0
- package/dist/server/collections/ai-tool-messages.js +1 -0
- package/dist/server/collections/lc-checkpoint-blobs.js +1 -0
- package/dist/server/collections/lc-checkpoint-writes.js +1 -0
- package/dist/server/collections/lc-checkpoints.js +1 -0
- package/dist/server/collections/llm-services.js +1 -0
- package/dist/server/collections/users-ai-employees.js +1 -0
- package/package.json +2 -2
- package/dist/ai/docs/nocobase/ai/install-upgrade-migration.mdx +0 -402
- package/dist/ai/docs/nocobase/api/cli/env/proxy/caddy.md +0 -108
- package/dist/ai/docs/nocobase/api/cli/env/proxy/index.md +0 -54
- package/dist/ai/docs/nocobase/api/cli/env/proxy/nginx.md +0 -104
|
@@ -1,163 +1,169 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Production Deployment"
|
|
3
|
-
description: "
|
|
4
|
-
keywords: "NocoBase,production deployment,nb app autostart,nb
|
|
3
|
+
description: "Finish NocoBase production deployment quickly: configure app auto-start first, then configure a reverse proxy."
|
|
4
|
+
keywords: "NocoBase,production deployment,nb app autostart,nb proxy nginx,nb proxy caddy,Nginx,Caddy"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Production Deployment
|
|
8
8
|
|
|
9
|
-
If your NocoBase app
|
|
9
|
+
If your NocoBase app can already run normally on the server, production rollout usually only needs two more things:
|
|
10
10
|
|
|
11
|
-
1.
|
|
12
|
-
2.
|
|
11
|
+
1. make sure the app can recover automatically after the machine restarts
|
|
12
|
+
2. add a reverse-proxy entrypoint so the app can be accessed from outside reliably
|
|
13
13
|
|
|
14
|
-
In
|
|
14
|
+
In NocoBase CLI, the main command groups are:
|
|
15
15
|
|
|
16
16
|
- `nb app autostart`
|
|
17
|
-
- `nb
|
|
17
|
+
- `nb proxy`
|
|
18
18
|
|
|
19
|
-
This page
|
|
19
|
+
This page explains the overall path first. For Nginx or Caddy details, continue to the provider-specific pages.
|
|
20
20
|
|
|
21
|
-
## Step 1:
|
|
21
|
+
## Step 1: configure app auto-start
|
|
22
22
|
|
|
23
|
-
In production, the first priority is not the domain name.
|
|
23
|
+
In production, the first priority is not the domain name. It is making sure the service itself can recover reliably. Otherwise, after a machine restart, container recreation, or routine operations work, the app may not come back automatically.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
The most common `nb app autostart` subcommands are:
|
|
26
26
|
|
|
27
27
|
- `nb app autostart enable`
|
|
28
28
|
- `nb app autostart list`
|
|
29
29
|
- `nb app autostart run`
|
|
30
30
|
|
|
31
|
-
Enable
|
|
31
|
+
Enable auto-start for the current env:
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
34
|
nb app autostart enable
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
If
|
|
37
|
+
If the target is not the current env, specify it explicitly:
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
40
|
nb app autostart enable --env app1 --yes
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
Check which envs are marked for auto-start:
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
46
|
nb app autostart list
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
After the system boots,
|
|
49
|
+
After the system boots, start all enabled envs with:
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
52
|
nb app autostart run
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
If you want
|
|
55
|
+
If you want detailed startup output while debugging:
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
58
|
nb app autostart run --verbose
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
:::tip What this actually does
|
|
61
|
+
:::tip What this step actually does
|
|
62
62
|
|
|
63
|
-
`nb app autostart enable` marks a CLI-managed env as allowed to start automatically.
|
|
64
|
-
`nb app autostart run` is the command that actually starts all envs that were marked for autostart.
|
|
63
|
+
`nb app autostart enable` marks a CLI-managed env as allowed to start automatically. `nb app autostart run` actually starts all envs that have auto-start enabled.
|
|
65
64
|
|
|
66
|
-
In
|
|
65
|
+
In production, you usually still need to connect `nb app autostart run` to your own system startup flow, such as `systemd`, a container platform startup script, or another host-level auto-start mechanism that you already use.
|
|
67
66
|
|
|
68
67
|
:::
|
|
69
68
|
|
|
70
|
-
###
|
|
69
|
+
### Applicability
|
|
71
70
|
|
|
72
|
-
`nb app autostart` only
|
|
71
|
+
`nb app autostart` only works for envs with a CLI-managed runtime:
|
|
73
72
|
|
|
74
73
|
- `local`
|
|
75
74
|
- `docker`
|
|
76
75
|
|
|
77
|
-
If
|
|
76
|
+
If an env is only a remote API connection, or the app is not managed locally by the CLI on the current machine, this command group is not the right way to handle auto-start.
|
|
78
77
|
|
|
79
|
-
## Step 2:
|
|
78
|
+
## Step 2: configure the reverse proxy
|
|
80
79
|
|
|
81
|
-
|
|
80
|
+
After the app can recover automatically, handle the external entrypoint. In production, the reverse proxy usually takes care of:
|
|
82
81
|
|
|
83
|
-
- binding the domain name or
|
|
84
|
-
- forwarding HTTP and WebSocket
|
|
82
|
+
- binding the domain name or entry port
|
|
83
|
+
- forwarding HTTP and WebSocket requests to NocoBase
|
|
85
84
|
- handling HTTPS, certificates, caching, or access control
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
The recommended CLI entrypoints are:
|
|
88
87
|
|
|
89
|
-
- `nb
|
|
90
|
-
- `nb
|
|
88
|
+
- `nb proxy nginx`
|
|
89
|
+
- `nb proxy caddy`
|
|
91
90
|
|
|
92
|
-
### Default
|
|
91
|
+
### Default workflow
|
|
93
92
|
|
|
94
|
-
If
|
|
93
|
+
If the app has already been saved as a CLI env and that env is `local` or `docker`, the usual path is to let the CLI generate the config directly:
|
|
95
94
|
|
|
96
95
|
```bash
|
|
97
|
-
nb
|
|
98
|
-
nb
|
|
96
|
+
nb proxy nginx use docker
|
|
97
|
+
nb proxy nginx generate --env app1 --host app.example.com
|
|
98
|
+
|
|
99
|
+
nb proxy caddy use local
|
|
100
|
+
nb proxy caddy generate --env app1 --host app.example.com
|
|
99
101
|
```
|
|
100
102
|
|
|
101
|
-
|
|
103
|
+
Then start the chosen provider:
|
|
102
104
|
|
|
103
105
|
```bash
|
|
104
|
-
nb
|
|
106
|
+
nb proxy nginx start
|
|
107
|
+
nb proxy caddy start
|
|
105
108
|
```
|
|
106
109
|
|
|
107
|
-
The CLI helps
|
|
110
|
+
The CLI also helps with details that are easy to miss in handwritten configs, such as:
|
|
108
111
|
|
|
109
112
|
- WebSocket forwarding
|
|
110
|
-
- entry and
|
|
113
|
+
- entry and asset URLs under subpaths
|
|
111
114
|
- SPA fallback pages
|
|
112
|
-
- provider shared config files
|
|
113
|
-
|
|
114
|
-
### When To Choose Nginx Or Caddy
|
|
115
|
+
- provider-level shared config files
|
|
115
116
|
|
|
116
|
-
|
|
117
|
+
### When to choose Nginx or Caddy
|
|
117
118
|
|
|
118
|
-
| Scenario |
|
|
119
|
+
| Scenario | Recommendation |
|
|
119
120
|
| --- | --- |
|
|
120
|
-
| You already use Nginx
|
|
121
|
-
| You already have a domain and want HTTPS
|
|
122
|
-
| You want the overall
|
|
121
|
+
| You already use Nginx to manage sites, caching, certificates, or access control | [Nginx](./reverse-proxy/nginx.md) |
|
|
122
|
+
| You already have a domain and want HTTPS up quickly with fewer TLS details to maintain | [Caddy](./reverse-proxy/caddy.md) |
|
|
123
|
+
| You want the overall introduction first | [Reverse Proxy in Production](./reverse-proxy/index.md) |
|
|
123
124
|
|
|
124
|
-
If you change env settings
|
|
125
|
+
If you later change env settings such as `app-port` or `app-public-path` that affect proxy behavior, rerun the matching proxy subcommand.
|
|
125
126
|
|
|
126
|
-
##
|
|
127
|
+
## Default rollout path
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
For the simplest production rollout, this sequence is usually enough:
|
|
129
130
|
|
|
130
|
-
1.
|
|
131
|
-
2.
|
|
132
|
-
3.
|
|
133
|
-
4.
|
|
134
|
-
5.
|
|
131
|
+
1. confirm the app can already start normally on the server itself
|
|
132
|
+
2. run `nb app autostart enable`
|
|
133
|
+
3. connect `nb app autostart run` to your system startup flow
|
|
134
|
+
4. choose Nginx or Caddy and run the matching `nb proxy` subcommand
|
|
135
|
+
5. verify external access through the domain name or entry address
|
|
135
136
|
|
|
136
|
-
## Quick
|
|
137
|
+
## Quick index
|
|
137
138
|
|
|
138
|
-
| I want to... |
|
|
139
|
+
| I want to... | Go here |
|
|
139
140
|
| --- | --- |
|
|
140
|
-
|
|
|
141
|
-
| Keep using Nginx
|
|
142
|
-
| Use Caddy
|
|
143
|
-
|
|
|
144
|
-
| Read the `nb
|
|
141
|
+
| Read the overall reverse-proxy introduction first | [Reverse Proxy in Production](./reverse-proxy/index.md) |
|
|
142
|
+
| Keep using Nginx at the entry layer | [Nginx](./reverse-proxy/nginx.md) |
|
|
143
|
+
| Use Caddy to get HTTPS faster | [Caddy](./reverse-proxy/caddy.md) |
|
|
144
|
+
| View app start, stop, logs, and upgrade operations | [Manage the App](../operations/manage-app.md) |
|
|
145
|
+
| Read the `nb proxy nginx` CLI reference | [`nb proxy nginx`](../../api/cli/proxy/nginx/index.md) |
|
|
146
|
+
| Read the `nb proxy caddy` CLI reference | [`nb proxy caddy`](../../api/cli/proxy/caddy/index.md) |
|
|
145
147
|
|
|
146
|
-
## Related
|
|
148
|
+
## Related commands
|
|
147
149
|
|
|
148
150
|
```bash
|
|
149
|
-
# Enable
|
|
151
|
+
# Enable auto-start for one env
|
|
150
152
|
nb app autostart enable --env app1 --yes
|
|
151
153
|
|
|
152
|
-
#
|
|
154
|
+
# Check auto-start state
|
|
153
155
|
nb app autostart list
|
|
154
156
|
|
|
155
|
-
# Start all envs
|
|
157
|
+
# Start all enabled envs
|
|
156
158
|
nb app autostart run
|
|
157
159
|
|
|
158
|
-
#
|
|
159
|
-
nb
|
|
160
|
+
# Choose the Nginx runtime and generate config
|
|
161
|
+
nb proxy nginx use docker
|
|
162
|
+
nb proxy nginx generate --env app1 --host app.example.com
|
|
163
|
+
nb proxy nginx start
|
|
160
164
|
|
|
161
|
-
#
|
|
162
|
-
nb
|
|
165
|
+
# Choose the Caddy runtime and generate config
|
|
166
|
+
nb proxy caddy use local
|
|
167
|
+
nb proxy caddy generate --env app1 --host app.example.com
|
|
168
|
+
nb proxy caddy start
|
|
163
169
|
```
|
|
@@ -1,158 +1,289 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "Caddy"
|
|
3
|
+
description: "Use nb proxy caddy to generate and manage Caddy reverse-proxy configuration for CLI-managed NocoBase envs."
|
|
4
|
+
keywords: "NocoBase,nb proxy caddy,reverse proxy,Caddy,production"
|
|
5
|
+
---
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
# Caddy
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
If you already have a domain and want to get HTTPS running quickly, `nb proxy caddy` is usually the simplest entry path.
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
Compared with maintaining certificate configuration in Nginx yourself, Caddy is more like the default shortcut for getting the entry layer online quickly.
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
## When Caddy is the better fit
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
- You do not want to maintain too many certificate and TLS details yourself
|
|
13
|
-
- You only need a simple and stable entry layer
|
|
15
|
+
In practice, Caddy is usually the better choice when:
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
- you already have a domain and want to get HTTPS online quickly
|
|
18
|
+
- you do not want to manage many certificate and TLS details yourself
|
|
19
|
+
- you mainly want a simple and stable entry layer
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
If you already use Nginx to manage many sites on the same server, or you still need heavier caching, access control, or custom rules, [Nginx](./nginx.md) is usually the better fit.
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
## Recommended order: choose a driver, generate config, then start
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
For a CLI-managed env of type `local` or `docker`, the default order is:
|
|
22
26
|
|
|
23
27
|
```bash
|
|
24
|
-
nb
|
|
28
|
+
nb proxy caddy use docker
|
|
29
|
+
nb proxy caddy generate --env test2 --host c.local.nocobase.com
|
|
30
|
+
nb proxy caddy start
|
|
25
31
|
```
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
Or with a local process:
|
|
28
34
|
|
|
29
35
|
```bash
|
|
30
|
-
nb
|
|
36
|
+
nb proxy caddy use local
|
|
37
|
+
nb proxy caddy generate --env test2 --host c.local.nocobase.com
|
|
38
|
+
nb proxy caddy start
|
|
31
39
|
```
|
|
32
40
|
|
|
33
|
-
|
|
41
|
+
Common follow-up commands are:
|
|
34
42
|
|
|
35
43
|
```bash
|
|
36
|
-
nb
|
|
44
|
+
nb proxy caddy current
|
|
45
|
+
nb proxy caddy status
|
|
46
|
+
nb proxy caddy info
|
|
47
|
+
nb proxy caddy reload
|
|
48
|
+
nb proxy caddy restart
|
|
49
|
+
nb proxy caddy stop
|
|
37
50
|
```
|
|
38
51
|
|
|
39
|
-
|
|
52
|
+
In most cases:
|
|
40
53
|
|
|
41
|
-
|
|
54
|
+
- `current` is the quickest way to confirm the active runtime driver
|
|
55
|
+
- `status` shows whether Caddy is currently running normally
|
|
56
|
+
- `info` shows the current config path, runtime root, and related runtime details
|
|
57
|
+
- after regenerating config, `reload` is usually the first command to use
|
|
58
|
+
- use `restart` when you need a full restart
|
|
42
59
|
|
|
43
|
-
|
|
60
|
+
## What `generate` needs as input
|
|
44
61
|
|
|
45
|
-
|
|
46
|
-
| --- | --- |
|
|
47
|
-
| `generated.caddy` | The actual reverse-proxy config managed by the CLI and overwritten every time you run `nb env proxy caddy` |
|
|
48
|
-
| `app.caddy` | Editable site entry file where you can add site-level config |
|
|
49
|
-
| `~/.nocobase/proxy/caddy/nocobase.caddy` | Shared main config that imports every env `app.caddy` |
|
|
62
|
+
The most common form is:
|
|
50
63
|
|
|
51
|
-
|
|
64
|
+
```bash
|
|
65
|
+
nb proxy caddy generate --env test2 --host c.local.nocobase.com
|
|
66
|
+
```
|
|
52
67
|
|
|
53
|
-
|
|
54
|
-
- `app.caddy` is editable, but you should keep the generated import inserted by the CLI
|
|
55
|
-
- `nocobase.caddy` is mainly used by `--install`
|
|
68
|
+
If you also want to specify the entry port:
|
|
56
69
|
|
|
57
|
-
|
|
70
|
+
```bash
|
|
71
|
+
nb proxy caddy generate --env test2 --host c.local.nocobase.com --port 8080
|
|
72
|
+
```
|
|
58
73
|
|
|
59
|
-
|
|
74
|
+
Where:
|
|
60
75
|
|
|
61
|
-
|
|
76
|
+
- `--env`: which CLI env to generate config for
|
|
77
|
+
- `--host`: the public domain name
|
|
78
|
+
- `--port`: the proxy entry port
|
|
62
79
|
|
|
63
|
-
|
|
80
|
+
For Caddy, `--host` matters especially because the site address strongly affects the HTTPS workflow. In production, it is usually best to pass a domain that already resolves to the current server.
|
|
64
81
|
|
|
65
|
-
If
|
|
82
|
+
If the command says the env is missing `appPort`, save it first with:
|
|
66
83
|
|
|
67
84
|
```bash
|
|
68
|
-
nb env
|
|
85
|
+
nb env update test2 --app-port 56575
|
|
69
86
|
```
|
|
70
87
|
|
|
71
|
-
|
|
88
|
+
If you later change settings such as `app-port` or `app-public-path` that affect proxy behavior, rerun `generate`.
|
|
72
89
|
|
|
73
|
-
|
|
74
|
-
- `--reload` validates the config first and then reloads Caddy
|
|
90
|
+
## Files maintained by the CLI
|
|
75
91
|
|
|
76
|
-
|
|
92
|
+
Using `test2` as an example, the Caddy workflow usually maintains:
|
|
77
93
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
94
|
+
| Path | Purpose |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| `NB_CLI_ROOT/.nocobase/proxy/caddy/test2/app.caddy` | CLI-generated full site config |
|
|
97
|
+
| `NB_CLI_ROOT/.nocobase/proxy/caddy/nocobase.caddy` | Provider-level Caddy entry file that imports all env `app.caddy` files |
|
|
98
|
+
| `NB_CLI_ROOT/.nocobase/proxy/caddy/test2/public/index-v1.html` | v1 SPA fallback page |
|
|
99
|
+
| `NB_CLI_ROOT/.nocobase/proxy/caddy/test2/public/index-v2.html` | v2 SPA fallback page |
|
|
100
|
+
| `NB_CLI_ROOT/test2/storage/dist-client` | Frontend build output for the current app |
|
|
101
|
+
| `NB_CLI_ROOT/test2/storage/uploads` | Uploads directory for the current app |
|
|
81
102
|
|
|
82
|
-
|
|
103
|
+
Where:
|
|
83
104
|
|
|
84
|
-
|
|
105
|
+
- files under `NB_CLI_ROOT/.nocobase/proxy/caddy/...` are CLI-managed proxy helper files
|
|
106
|
+
- files under `NB_CLI_ROOT/test2/storage/...` belong to the application itself
|
|
107
|
+
- `nocobase.caddy` is the provider-level entry file and usually does not need manual edits
|
|
108
|
+
- `app.caddy` is the full site config for one env and is overwritten as a whole when you regenerate it
|
|
85
109
|
|
|
86
|
-
|
|
110
|
+
:::warning Note
|
|
87
111
|
|
|
88
|
-
|
|
89
|
-
nb config set proxy.nb-cli-root /workspace
|
|
90
|
-
nb env proxy caddy --env demo --install --reload
|
|
91
|
-
```
|
|
112
|
+
If you need site-level Caddy config such as extra headers, authentication, rate limiting, or compression policy, you can adjust `app.caddy` as the baseline. But remember that running `generate` again overwrites that file.
|
|
92
113
|
|
|
93
|
-
|
|
114
|
+
:::
|
|
94
115
|
|
|
95
|
-
|
|
96
|
-
nb env proxy caddy --env demo --print
|
|
97
|
-
```
|
|
116
|
+
## Handwritten config: when you are not using the CLI
|
|
98
117
|
|
|
99
|
-
If you want to
|
|
118
|
+
If the app is not CLI-managed, or you intentionally want to maintain the full Caddy config yourself, you can still write it by hand.
|
|
100
119
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
120
|
+
For NocoBase, though, a production entry is usually more than a simple `reverse_proxy`. In addition to forwarding API requests to the backend app, a complete Caddy config usually needs to handle uploads, frontend assets, `.well-known` routes, WebSocket, and SPA fallback pages together.
|
|
121
|
+
|
|
122
|
+
Using `test2` as the example, the key Caddy-related paths usually include:
|
|
104
123
|
|
|
105
|
-
|
|
124
|
+
- SPA fallback directory: `NB_CLI_ROOT/.nocobase/proxy/caddy/test2/public`
|
|
125
|
+
- Frontend build output: `NB_CLI_ROOT/test2/storage/dist-client`
|
|
126
|
+
- Uploads directory: `NB_CLI_ROOT/test2/storage/uploads`
|
|
106
127
|
|
|
107
|
-
|
|
128
|
+
In other words, a handwritten config usually needs to cover at least these entry areas:
|
|
108
129
|
|
|
109
|
-
|
|
130
|
+
- `v`: redirect `/v` to `/v/`
|
|
131
|
+
- `uploads`: expose the uploads directory
|
|
132
|
+
- `dist`: expose the frontend build output
|
|
133
|
+
- `oauth well-known`: handle the OAuth discovery path
|
|
134
|
+
- `openid well-known`: handle the OpenID discovery path
|
|
135
|
+
- `api`: forward `/api/` requests to the backend app
|
|
136
|
+
- `ws`: forward WebSocket requests to the backend app
|
|
137
|
+
- `spa v2`: serve `/v/` with the v2 entry and fallback page
|
|
138
|
+
- `spa v1`: serve `/` with the v1 entry and fallback page
|
|
139
|
+
|
|
140
|
+
So a complete Caddy config is usually more than a generic example such as:
|
|
110
141
|
|
|
111
142
|
```text
|
|
112
143
|
your-domain.com {
|
|
113
|
-
encode zstd gzip
|
|
114
144
|
reverse_proxy 127.0.0.1:13000
|
|
115
145
|
}
|
|
116
146
|
```
|
|
117
147
|
|
|
118
|
-
|
|
148
|
+
For a CLI-managed app such as `test2`, a more realistic deployment structure usually looks closer to this:
|
|
149
|
+
|
|
150
|
+
```text
|
|
151
|
+
c.local.nocobase.com {
|
|
152
|
+
encode zstd gzip
|
|
153
|
+
|
|
154
|
+
handle /v {
|
|
155
|
+
redir * /v/ 302
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
handle_path /storage/uploads/* {
|
|
159
|
+
root * NB_CLI_ROOT/test2/storage/uploads
|
|
160
|
+
header Cache-Control public
|
|
161
|
+
header X-Content-Type-Options nosniff
|
|
162
|
+
file_server
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
handle_path /dist/* {
|
|
166
|
+
root * NB_CLI_ROOT/test2/storage/dist-client
|
|
167
|
+
header Cache-Control public
|
|
168
|
+
file_server
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@oauth path_regexp oauth ^/\\.well-known/oauth-authorization-server/(.+)$
|
|
172
|
+
handle @oauth {
|
|
173
|
+
rewrite * /{re.oauth.1}/.well-known/oauth-authorization-server
|
|
174
|
+
reverse_proxy host.docker.internal:56575
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@openid path_regexp openid ^/\\.well-known/openid-configuration/(.+)$
|
|
178
|
+
handle @openid {
|
|
179
|
+
rewrite * /{re.openid.1}/.well-known/openid-configuration
|
|
180
|
+
reverse_proxy host.docker.internal:56575
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
handle /api/* {
|
|
184
|
+
reverse_proxy host.docker.internal:56575
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
handle /ws {
|
|
188
|
+
reverse_proxy host.docker.internal:56575
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
handle_path /v/* {
|
|
192
|
+
root * NB_CLI_ROOT/.nocobase/proxy/caddy/test2/public
|
|
193
|
+
header Cache-Control "no-store, no-cache, must-revalidate"
|
|
194
|
+
header X-Robots-Tag "noindex, nofollow"
|
|
195
|
+
try_files {path} /index-v2.html
|
|
196
|
+
file_server
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
handle_path /* {
|
|
200
|
+
root * NB_CLI_ROOT/.nocobase/proxy/caddy/test2/public
|
|
201
|
+
header Cache-Control "no-store, no-cache, must-revalidate"
|
|
202
|
+
header X-Robots-Tag "noindex, nofollow"
|
|
203
|
+
try_files {path} /index-v1.html
|
|
204
|
+
file_server
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Two details matter here:
|
|
119
210
|
|
|
120
|
-
-
|
|
121
|
-
-
|
|
211
|
+
- files under `NB_CLI_ROOT/.nocobase/proxy/caddy/...` are CLI-managed SPA fallback files
|
|
212
|
+
- files under `NB_CLI_ROOT/test2/storage/...` belong to the application's own build output and uploads
|
|
213
|
+
|
|
214
|
+
If the app uses subpath deployment, or if frontend assets, uploads, and the entry layer do not share the same path view, handwritten config becomes easier to get wrong. In those cases, it is usually safer to generate the config first with:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
nb proxy caddy generate --env test2 --host c.local.nocobase.com
|
|
218
|
+
```
|
|
122
219
|
|
|
123
|
-
|
|
220
|
+
Then use the generated result as the baseline for manual adjustments.
|
|
124
221
|
|
|
125
|
-
If you
|
|
222
|
+
If you want the CLI to get the routes and paths working first, the generated structure usually looks like this:
|
|
126
223
|
|
|
127
224
|
```text
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
225
|
+
NB_CLI_ROOT/.nocobase/proxy/caddy/nocobase.caddy
|
|
226
|
+
NB_CLI_ROOT/.nocobase/proxy/caddy/test2/app.caddy
|
|
227
|
+
NB_CLI_ROOT/.nocobase/proxy/caddy/test2/public/index-v1.html
|
|
228
|
+
NB_CLI_ROOT/.nocobase/proxy/caddy/test2/public/index-v2.html
|
|
229
|
+
NB_CLI_ROOT/test2/storage/dist-client
|
|
230
|
+
NB_CLI_ROOT/test2/storage/uploads
|
|
131
231
|
```
|
|
132
232
|
|
|
133
|
-
|
|
233
|
+
Where:
|
|
234
|
+
|
|
235
|
+
- `nocobase.caddy` imports all `*/app.caddy` files
|
|
236
|
+
- `test2/app.caddy` is the full site config for env `test2`
|
|
237
|
+
- `public/index-v1.html` and `public/index-v2.html` are CLI-generated SPA fallback pages
|
|
238
|
+
|
|
239
|
+
The safer workflow is usually:
|
|
240
|
+
|
|
241
|
+
1. let the CLI generate the Caddy config first
|
|
242
|
+
2. use the generated output to confirm the routing structure and real filesystem paths
|
|
243
|
+
3. then adjust it for your own domain, runtime driver, and mount layout
|
|
134
244
|
|
|
135
|
-
|
|
245
|
+
That is usually less error-prone than writing the full config from scratch.
|
|
136
246
|
|
|
137
247
|
## Validate and reload the config
|
|
138
248
|
|
|
249
|
+
If you write or adjust Caddy config manually, validate it first and then reload:
|
|
250
|
+
|
|
139
251
|
```bash
|
|
140
252
|
caddy validate --config /etc/caddy/Caddyfile
|
|
141
253
|
systemctl reload caddy
|
|
142
254
|
```
|
|
143
255
|
|
|
144
|
-
If you
|
|
256
|
+
If you are not using `systemd` to manage Caddy, replace that with your own start and reload workflow.
|
|
257
|
+
|
|
258
|
+
If you manage the entry layer through `nb proxy caddy`, the usual first choice is:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
nb proxy caddy reload
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
If you want to inspect the current driver, main config-file path, runtime root, and container or local binary details, run:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
nb proxy caddy info
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
If you only want to confirm whether Caddy is already running, run:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
nb proxy caddy status
|
|
274
|
+
```
|
|
145
275
|
|
|
146
|
-
##
|
|
276
|
+
## Common notes
|
|
147
277
|
|
|
148
|
-
- `nb
|
|
149
|
-
-
|
|
150
|
-
-
|
|
151
|
-
-
|
|
278
|
+
- `nb proxy caddy generate` only works for CLI-managed envs whose runtime is reachable from the current machine, which means `local` or `docker`
|
|
279
|
+
- if the command says the env is missing `appPort`, run `nb env update <name> --app-port <port>` first
|
|
280
|
+
- if you already have a domain that resolves correctly to the current server, Caddy is often the fastest way to get HTTPS
|
|
281
|
+
- if you later change settings such as `app-port` or `app-public-path` that affect proxy behavior, rerun `generate`
|
|
152
282
|
|
|
153
283
|
## Related links
|
|
154
284
|
|
|
155
|
-
- [
|
|
156
|
-
- [
|
|
285
|
+
- [Reverse Proxy in Production](./index.md)
|
|
286
|
+
- [Nginx](./nginx.md)
|
|
287
|
+
- [Install with the CLI](../../installation/cli.md)
|
|
157
288
|
- [Install with Docker Compose](../../installation/docker-compose.md)
|
|
158
|
-
- [
|
|
289
|
+
- [Environment variables](../../installation/env.md)
|