@nocobase/plugin-ai 2.1.0-beta.46 → 2.1.0-beta.47

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.
Files changed (74) hide show
  1. package/dist/ai/docs/nocobase/api/cli/config/delete.md +7 -5
  2. package/dist/ai/docs/nocobase/api/cli/config/get.md +7 -5
  3. package/dist/ai/docs/nocobase/api/cli/config/index.md +38 -18
  4. package/dist/ai/docs/nocobase/api/cli/config/set.md +9 -7
  5. package/dist/ai/docs/nocobase/api/cli/env/index.md +19 -20
  6. package/dist/ai/docs/nocobase/api/cli/env/update.md +72 -72
  7. package/dist/ai/docs/nocobase/api/cli/proxy/caddy/current.md +33 -0
  8. package/dist/ai/docs/nocobase/api/cli/proxy/caddy/generate.md +54 -0
  9. package/dist/ai/docs/nocobase/api/cli/proxy/caddy/index.md +60 -0
  10. package/dist/ai/docs/nocobase/api/cli/proxy/caddy/info.md +42 -0
  11. package/dist/ai/docs/nocobase/api/cli/proxy/caddy/reload.md +32 -0
  12. package/dist/ai/docs/nocobase/api/cli/proxy/caddy/restart.md +32 -0
  13. package/dist/ai/docs/nocobase/api/cli/proxy/caddy/start.md +32 -0
  14. package/dist/ai/docs/nocobase/api/cli/proxy/caddy/status.md +36 -0
  15. package/dist/ai/docs/nocobase/api/cli/proxy/caddy/stop.md +32 -0
  16. package/dist/ai/docs/nocobase/api/cli/proxy/caddy/use.md +38 -0
  17. package/dist/ai/docs/nocobase/api/cli/proxy/index.md +124 -0
  18. package/dist/ai/docs/nocobase/api/cli/proxy/nginx/current.md +33 -0
  19. package/dist/ai/docs/nocobase/api/cli/proxy/nginx/generate.md +62 -0
  20. package/dist/ai/docs/nocobase/api/cli/proxy/nginx/index.md +60 -0
  21. package/dist/ai/docs/nocobase/api/cli/proxy/nginx/info.md +43 -0
  22. package/dist/ai/docs/nocobase/api/cli/proxy/nginx/reload.md +32 -0
  23. package/dist/ai/docs/nocobase/api/cli/proxy/nginx/restart.md +32 -0
  24. package/dist/ai/docs/nocobase/api/cli/proxy/nginx/start.md +32 -0
  25. package/dist/ai/docs/nocobase/api/cli/proxy/nginx/status.md +36 -0
  26. package/dist/ai/docs/nocobase/api/cli/proxy/nginx/stop.md +32 -0
  27. package/dist/ai/docs/nocobase/api/cli/proxy/nginx/use.md +38 -0
  28. package/dist/ai/docs/nocobase/ops-management/version-control/index.md +73 -0
  29. package/dist/ai/docs/nocobase/quickstart/production/index.md +75 -69
  30. package/dist/ai/docs/nocobase/quickstart/production/reverse-proxy/caddy.md +211 -80
  31. package/dist/ai/docs/nocobase/quickstart/production/reverse-proxy/index.md +72 -53
  32. package/dist/ai/docs/nocobase/quickstart/production/reverse-proxy/nginx.md +186 -89
  33. package/dist/client/{290.0888139e33c9b7cb.js → 290.0f7f441d8a94f03c.js} +1 -1
  34. package/dist/client/{428.431a00d29107058e.js → 428.fdd0cc3cfd1632ef.js} +1 -1
  35. package/dist/client/ai-employees/chatbox/hooks/useChat.d.ts +14 -14
  36. package/dist/client/ai-employees/chatbox/stores/chat-box.d.ts +1 -105
  37. package/dist/client/ai-employees/chatbox/stores/chat-conversations.d.ts +1 -37
  38. package/dist/client/ai-employees/chatbox/stores/chat-messages.d.ts +1 -109
  39. package/dist/client/index.js +3 -3
  40. package/dist/client-v2/ai-employees/chatbox/hooks/useChatBoxActions.d.ts +17 -0
  41. package/dist/client-v2/ai-employees/chatbox/stores/chat-box.d.ts +113 -0
  42. package/dist/client-v2/ai-employees/chatbox/stores/chat-conversations.d.ts +45 -0
  43. package/dist/client-v2/ai-employees/chatbox/stores/chat-messages.d.ts +118 -0
  44. package/dist/client-v2/ai-employees/chatbox/stores/create-selectors.d.ts +18 -0
  45. package/dist/client-v2/ai-employees/chatbox/stores/global-store.d.ts +9 -0
  46. package/dist/client-v2/ai-employees/types.d.ts +151 -0
  47. package/dist/client-v2/index.d.ts +8 -1
  48. package/dist/client-v2/index.js +1 -1
  49. package/dist/client-v2/repositories/AIConfigRepository.d.ts +81 -0
  50. package/dist/client-v2/repositories/hooks/useAIConfigRepository.d.ts +10 -0
  51. package/dist/collections/ai-context-datasource.js +1 -0
  52. package/dist/externalVersion.js +16 -16
  53. package/dist/node_modules/@langchain/xai/package.json +1 -1
  54. package/dist/node_modules/fs-extra/package.json +1 -1
  55. package/dist/node_modules/jsonrepair/package.json +1 -1
  56. package/dist/node_modules/just-bash/package.json +1 -1
  57. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  58. package/dist/node_modules/openai/package.json +1 -1
  59. package/dist/node_modules/zod/package.json +1 -1
  60. package/dist/server/collections/ai-conversations.js +1 -0
  61. package/dist/server/collections/ai-employees.js +1 -0
  62. package/dist/server/collections/ai-files.js +1 -0
  63. package/dist/server/collections/ai-messages.js +1 -0
  64. package/dist/server/collections/ai-settings.js +1 -0
  65. package/dist/server/collections/ai-tool-messages.js +1 -0
  66. package/dist/server/collections/lc-checkpoint-blobs.js +1 -0
  67. package/dist/server/collections/lc-checkpoint-writes.js +1 -0
  68. package/dist/server/collections/lc-checkpoints.js +1 -0
  69. package/dist/server/collections/llm-services.js +1 -0
  70. package/dist/server/collections/users-ai-employees.js +1 -0
  71. package/package.json +2 -2
  72. package/dist/ai/docs/nocobase/api/cli/env/proxy/caddy.md +0 -108
  73. package/dist/ai/docs/nocobase/api/cli/env/proxy/index.md +0 -54
  74. package/dist/ai/docs/nocobase/api/cli/env/proxy/nginx.md +0 -104
@@ -1,158 +1,289 @@
1
- # Caddy
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
- If you already have a domain and want to get HTTPS running quickly, Caddy is usually the easiest choice. Compared with maintaining Nginx certificate config yourself, Caddy is more like the shortcut path for getting the entry layer online first.
7
+ # Caddy
4
8
 
5
- The default recommendation is to run `nb env proxy caddy` directly.
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
- ## When Caddy is usually the better fit
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
- These cases usually favor Caddy first:
13
+ ## When Caddy is the better fit
10
14
 
11
- - You already have a domain and want HTTPS quickly
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
- If you already use Nginx across the server to manage many sites, or you still need heavier caching, access control, and custom rules, [Nginx](./nginx.md) is usually the better fit.
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
- ## Default path: let the CLI generate the Caddy config
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
- If your app has already been saved as a CLI env and the env type is `local` or `docker`, the default recommendation is still to let the CLI generate the config. That way, routing details related to NocoBase paths, WebSocket handling, and subpaths stay managed by the CLI, and you only need to care about the site entry itself.
23
+ ## Recommended order: choose a driver, generate config, then start
20
24
 
21
- The most direct form is:
25
+ For a CLI-managed env of type `local` or `docker`, the default order is:
22
26
 
23
27
  ```bash
24
- nb env proxy caddy --env demo --host demo.example.com
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
- If you have already switched to the current env, you can also omit `--env`:
33
+ Or with a local process:
28
34
 
29
35
  ```bash
30
- nb env proxy caddy --host demo.example.com
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
- If you also want to specify the entry port, add it at the same time:
41
+ Common follow-up commands are:
34
42
 
35
43
  ```bash
36
- nb env proxy caddy --env demo --host demo.example.com --port 8080
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
- `--host` is important here. Caddy decides whether to manage HTTPS based on the site address. In production, try to pass a domain that already resolves to the current server.
52
+ In most cases:
40
53
 
41
- ### Which files the CLI generates
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
- If you do not pass `--output`, the Caddy provider keeps three layers of files under `~/.nocobase/proxy/caddy/<env>/`:
60
+ ## What `generate` needs as input
44
61
 
45
- | File | Purpose |
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
- Where:
64
+ ```bash
65
+ nb proxy caddy generate --env test2 --host c.local.nocobase.com
66
+ ```
52
67
 
53
- - `generated.caddy` is only meant to be managed by the CLI and should not be edited manually
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
- :::warning Note
70
+ ```bash
71
+ nb proxy caddy generate --env test2 --host c.local.nocobase.com --port 8080
72
+ ```
58
73
 
59
- If you need to add site-level Caddy config such as extra headers, authentication, rate limiting, or compression rules, edit `app.caddy`. `generated.caddy` will be overwritten the next time you run `nb env proxy caddy`.
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
- ### Install the shared config into Caddy and reload it
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 you want the CLI to connect the shared config to the Caddy main config and immediately validate and reload Caddy, run:
82
+ If the command says the env is missing `appPort`, save it first with:
66
83
 
67
84
  ```bash
68
- nb env proxy caddy --env demo --host demo.example.com --install --reload
85
+ nb env update test2 --app-port 56575
69
86
  ```
70
87
 
71
- These flags are split like this:
88
+ If you later change settings such as `app-port` or `app-public-path` that affect proxy behavior, rerun `generate`.
72
89
 
73
- - `--install` connects `~/.nocobase/proxy/caddy/nocobase.caddy` to the Caddy main config
74
- - `--reload` validates the config first and then reloads Caddy
90
+ ## Files maintained by the CLI
75
91
 
76
- If your Caddy executable is not on the default path, set the CLI config first:
92
+ Using `test2` as an example, the Caddy workflow usually maintains:
77
93
 
78
- ```bash
79
- nb config set bin.caddy /usr/bin/caddy
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
- ### When should you change `proxy.nb-cli-root`
103
+ Where:
83
104
 
84
- Most setups do not need to change `proxy.nb-cli-root`. You usually need it only when Caddy runs in another container, mount root, or path view and cannot see the current user's `~/.nocobase` path.
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
- For example, if Caddy sees that path as `/workspace/.nocobase/...` inside a container, set:
110
+ :::warning Note
87
111
 
88
- ```bash
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
- If you only want to preview the generated result, use:
114
+ :::
94
115
 
95
- ```bash
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 write the generated route fragment to a custom file, use:
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
- ```bash
102
- nb env proxy caddy --env demo --output ./generated.caddy
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
- For the full parameter reference, see [`nb env proxy caddy`](../../../api/cli/env/proxy/caddy.md).
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
- ## Handwritten config: what to do without the CLI
128
+ In other words, a handwritten config usually needs to cover at least these entry areas:
108
129
 
109
- If your app is not managed by the CLI, or you explicitly want to maintain the full `Caddyfile` yourself, start with this minimal version:
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
- Where:
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
- - Replace `your-domain.com` with your domain
121
- - Replace `127.0.0.1:13000` with the real address your NocoBase app listens on
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
- If the domain already resolves to the current server correctly, Caddy usually handles HTTPS certificate issuance and renewal automatically.
220
+ Then use the generated result as the baseline for manual adjustments.
124
221
 
125
- If you do not have a domain yet and only want to verify the reverse-proxy chain first, you can listen on a port:
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
- :80 {
129
- reverse_proxy 127.0.0.1:13000
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
- In production, though, it is still better to switch to a domain-based site address as soon as possible so Caddy can also take over HTTPS.
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
- If your app is not mounted at `/` but under a subpath, handwritten Caddy config also means you need to confirm application variables such as `APP_PUBLIC_PATH` and `WS_PATH`. In that case, it is usually easier to go back to `nb env proxy caddy` and let the CLI generate the config.
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 do not manage Caddy with `systemd`, use your own startup and reload workflow.
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
- ## Notes
276
+ ## Common notes
147
277
 
148
- - `nb env proxy caddy` only works for CLI-managed envs whose runtime is reachable from the current machine, which means `local` or `docker`
149
- - If the command says the env is missing `appPort`, run `nb env update <name> --app-port <port>` first
150
- - `--output` and `--print` are useful for preview or custom integration, but they do not additionally create `app.caddy` or the shared main config
151
- - If you already have a domain that resolves correctly to the server, Caddy is often the fastest way to get HTTPS working
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
- - [`nb env proxy caddy`](../../../api/cli/env/proxy/caddy.md)
156
- - [Install with CLI (Recommended)](../../installation/cli.md)
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
- - [App Environment Variables](../../installation/env.md)
289
+ - [Environment variables](../../installation/env.md)
@@ -1,69 +1,94 @@
1
1
  ---
2
- title: 'Reverse Proxy for Production'
3
- description: 'Use nb env proxy nginx and nb env proxy caddy to generate reverse-proxy configs for CLI-managed NocoBase envs.'
4
- keywords: 'NocoBase,nb env proxy nginx,nb env proxy caddy,reverse proxy,Nginx,Caddy,production'
2
+ title: "Reverse Proxy in Production"
3
+ description: "Use nb proxy nginx and nb proxy caddy to generate and manage reverse-proxy configuration for CLI-managed NocoBase envs."
4
+ keywords: "NocoBase,nb proxy nginx,nb proxy caddy,reverse proxy,Nginx,Caddy,production"
5
5
  ---
6
6
 
7
- # Reverse Proxy for Production
7
+ # Reverse Proxy in Production
8
8
 
9
- In NocoBase CLI, there are two recommended entry points for putting a reverse proxy in front of a production app:
9
+ In NocoBase CLI, the recommended production reverse-proxy entrypoints are:
10
10
 
11
- - `nb env proxy nginx`
12
- - `nb env proxy caddy`
11
+ - `nb proxy nginx`
12
+ - `nb proxy caddy`
13
13
 
14
- As long as your app has already been saved as a CLI env and the env type is `local` or `docker`, letting the CLI generate the config is usually enough. That way, the CLI keeps tricky details such as WebSocket handling, subpaths, SPA fallback pages, and later updates in sync. You only need to decide whether the entry layer should keep using Nginx or move to Caddy.
14
+ Where:
15
+
16
+ - `proxy` manages the entry layer
17
+ - `nginx` and `caddy` are the provider implementations
18
+ - `docker` and `local` are the runtime drivers
19
+ - `--env <name>` selects which CLI env to generate config for
20
+
21
+ As long as your app has been saved as a CLI-managed env and the env is `local` or `docker`, letting the CLI generate and manage the reverse-proxy config is usually enough. That approach keeps WebSocket handling, subpaths, SPA fallback pages, and later updates aligned in one place.
15
22
 
16
- If your app is not managed by the CLI, or if you explicitly want to handwrite the full proxy config, go straight to the handwritten-config section in the provider pages.
23
+ If the app is not CLI-managed, or you intentionally want to maintain the entire proxy configuration by hand, move on to the handwritten-config sections in the provider-specific pages.
17
24
 
18
- ## Check whether this path fits your setup
25
+ ## Before you start
19
26
 
20
- - Your app is already reachable through an internal address such as `http://127.0.0.1:13000`
21
- - The app has already been saved as a CLI env, and the env type is `local` or `docker`
22
- - The env already has `appPort` saved
27
+ Make sure that:
23
28
 
24
- If the command says the env is missing `appPort`, run [`nb env update`](../../../api/cli/env/update.md) first and save it.
29
+ - the app can already be reached internally, such as `http://127.0.0.1:13000`
30
+ - the app has already been saved as a CLI env, and that env is `local` or `docker`
31
+ - the env already has `appPort` saved
25
32
 
26
- If you later change settings such as `app-port` or `app-public-path` that affect proxy output, remember to rerun the matching proxy subcommand.
33
+ If the command says the env is missing `appPort`, update it first with [`nb env update`](../../../api/cli/env/update.md).
27
34
 
28
- ## Default path: let the CLI generate the config first
35
+ If you later change settings such as `app-port` or `app-public-path` that affect proxy behavior, rerun the matching `generate` command.
29
36
 
30
- If you already know which entry provider you want to keep using, go straight to that subcommand:
37
+ ## Default workflow
38
+
39
+ For Nginx:
31
40
 
32
41
  ```bash
33
- nb env proxy nginx --env demo --host demo.example.com
34
- nb env proxy caddy --env demo --host demo.example.com
42
+ nb proxy nginx use docker
43
+ nb proxy nginx generate --env test2 --host c.local.nocobase.com
44
+ nb proxy nginx start
35
45
  ```
36
46
 
37
- If you have already switched to the current env, you can also omit `--env`:
47
+ For Caddy:
38
48
 
39
49
  ```bash
40
- nb env proxy nginx --host demo.example.com
50
+ nb proxy caddy use local
51
+ nb proxy caddy generate --env test2 --host c.local.nocobase.com
52
+ nb proxy caddy start
41
53
  ```
42
54
 
43
- Where:
55
+ The roles are:
44
56
 
45
- - If you already use Nginx to manage sites, caching, access control, or certificates, start with [`nb env proxy nginx`](../../../api/cli/env/proxy/nginx.md)
46
- - If you want HTTPS running quickly and do not want to maintain many TLS details yourself, start with [`nb env proxy caddy`](../../../api/cli/env/proxy/caddy.md)
47
- - `--port` is the proxy entry port, not the app `appPort`
57
+ - `use docker|local`: choose the runtime driver for the current provider
58
+ - `generate --env <name> --host <domain>`: generate reverse-proxy config for one env
59
+ - `start`: start the local process or Docker container for the current provider
48
60
 
49
- If you want the CLI to also connect the shared config to the provider main config and reload it after validation, add:
61
+ If you update the config later, `reload` is usually the first choice. Use `restart` when you need a full restart of the entry layer.
50
62
 
51
- ```bash
52
- nb env proxy nginx --env demo --host demo.example.com --install --reload
53
- ```
63
+ ## How the command group is split
64
+
65
+ Using Nginx as the example:
66
+
67
+ | Command | Purpose |
68
+ | --- | --- |
69
+ | `nb proxy nginx use docker` | Switch the Nginx runtime to Docker |
70
+ | `nb proxy nginx use local` | Switch the Nginx runtime to a local process |
71
+ | `nb proxy nginx current` | Show the current runtime driver |
72
+ | `nb proxy nginx generate --env <name> --host <domain>` | Generate Nginx config for one env |
73
+ | `nb proxy nginx start` | Start Nginx |
74
+ | `nb proxy nginx reload` | Reload the Nginx config |
75
+ | `nb proxy nginx restart` | Restart Nginx |
76
+ | `nb proxy nginx stop` | Stop Nginx |
77
+ | `nb proxy nginx status` | Show Nginx status |
78
+ | `nb proxy nginx info` | Show the current config, paths, and runtime details |
54
79
 
55
- For the full command reference, see [`nb env proxy`](../../../api/cli/env/proxy/index.md).
80
+ Caddy uses the same action set, but with a different provider implementation.
56
81
 
57
- ## What the CLI keeps in sync for you
82
+ ## What the CLI maintains
58
83
 
59
- The CLI does more than generate one proxy snippet. It also maintains provider-specific helper files. The output shape differs between the two providers:
84
+ The CLI does more than produce one proxy fragment. It also keeps the helper files and site entry structure aligned with the provider:
60
85
 
61
- - Nginx keeps `app.conf`, `public/index-v1.html`, `public/index-v2.html`, the shared `nocobase.conf`, and the shared `snippets/`
62
- - Caddy keeps `generated.caddy`, `app.caddy`, and the shared `nocobase.caddy`
86
+ - Nginx maintains shared `snippets`, `app.conf`, `public/index-v1.html`, and `public/index-v2.html`
87
+ - Caddy maintains `nocobase.caddy`, `app.caddy`, `public/index-v1.html`, and `public/index-v2.html`, where `app.caddy` is the full site config for one env
63
88
 
64
89
  :::warning Note
65
90
 
66
- If you need to add site-level configuration, edit `app.conf` or `app.caddy`. Do not manually edit CLI-managed helper files, because they will be overwritten the next time you run the command.
91
+ If you need to add site-level configuration, you usually edit `app.conf` for Nginx and use `app.caddy` as the base for Caddy. Do not edit the CLI-managed helper files directly. Also note that `app.caddy` is overwritten as a whole when you run `generate` again, while `nocobase.caddy` mainly serves as the provider-level entry file.
67
92
 
68
93
  :::
69
94
 
@@ -71,30 +96,24 @@ If you need to add site-level configuration, edit `app.conf` or `app.caddy`. Do
71
96
 
72
97
  | I want to... | Go here |
73
98
  | --- | --- |
74
- | Keep using Nginx to manage sites, certificates, caching, or access control | [Nginx](./nginx.md) |
75
- | Get HTTPS running quickly and maintain fewer certificate and TLS details | [Caddy](./caddy.md) |
76
- | Review the command tree and choose a provider first | [`nb env proxy`](../../../api/cli/env/proxy/index.md) |
77
- | See the Nginx subcommand options, output files, and examples first | [`nb env proxy nginx`](../../../api/cli/env/proxy/nginx.md) |
78
- | See the Caddy subcommand options, output files, and examples first | [`nb env proxy caddy`](../../../api/cli/env/proxy/caddy.md) |
79
- | Adjust env settings that may affect proxy output, such as `app-port` or `app-public-path` | [`nb env update`](../../../api/cli/env/update.md) |
80
- | Install the app as a CLI-managed env first | [Install with CLI (Recommended)](../../installation/cli.md) |
99
+ | Keep using Nginx for sites, certificates, caching, or access control | [Nginx](./nginx.md) |
100
+ | Get HTTPS running quickly with fewer TLS details to maintain | [Caddy](./caddy.md) |
101
+ | Adjust env settings that may affect proxy behavior, such as `app-port` or `app-public-path` | [`nb env update`](../../../api/cli/env/update.md) |
102
+ | Install the app as a CLI-managed env first | [Install with the CLI](../../installation/cli.md) |
81
103
 
82
- ## When the CLI-generated path is not the best fit
104
+ ## When the CLI path is not the right fit
83
105
 
84
- These cases are usually better served by the handwritten-config section in the provider pages:
106
+ In these cases, the handwritten-config sections in the provider-specific pages are usually a better fit:
85
107
 
86
- - Your app is not managed by the CLI
87
- - The env only has a remote API connection, or it is an SSH env
88
- - You explicitly want to maintain the full Nginx config or full `Caddyfile` yourself
108
+ - the app is not CLI-managed
109
+ - the env is only a remote API connection or an SSH env
110
+ - you intentionally want to maintain the entire Nginx config or `Caddyfile` yourself
89
111
 
90
- As long as the app has already been saved as a CLI env and the current machine can reach its runtime, the default recommendation is still to start with these commands. It makes later domain changes, site-level adjustments, and regeneration much easier to manage.
112
+ As long as the app has been saved as a CLI env and its runtime is reachable from the current machine, using this command group is still the recommended default. It is usually much easier to maintain later when you need to change the domain, add site-level config, switch drivers, or regenerate the entry files.
91
113
 
92
114
  ## Related links
93
115
 
94
- - [`nb env proxy`](../../../api/cli/env/proxy/index.md)
95
- - [`nb env proxy nginx`](../../../api/cli/env/proxy/nginx.md)
96
- - [`nb env proxy caddy`](../../../api/cli/env/proxy/caddy.md)
97
116
  - [Nginx](./nginx.md)
98
117
  - [Caddy](./caddy.md)
99
- - [App Environment Variables](../../installation/env.md)
100
- - [Install with CLI (Recommended)](../../installation/cli.md)
118
+ - [Environment variables](../../installation/env.md)
119
+ - [Install with the CLI](../../installation/cli.md)