@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,69 +1,94 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description:
|
|
4
|
-
keywords:
|
|
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
|
|
7
|
+
# Reverse Proxy in Production
|
|
8
8
|
|
|
9
|
-
In NocoBase CLI,
|
|
9
|
+
In NocoBase CLI, the recommended production reverse-proxy entrypoints are:
|
|
10
10
|
|
|
11
|
-
- `nb
|
|
12
|
-
- `nb
|
|
11
|
+
- `nb proxy nginx`
|
|
12
|
+
- `nb proxy caddy`
|
|
13
13
|
|
|
14
|
-
|
|
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
|
|
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
|
-
##
|
|
25
|
+
## Before you start
|
|
19
26
|
|
|
20
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
37
|
+
## Default workflow
|
|
38
|
+
|
|
39
|
+
For Nginx:
|
|
31
40
|
|
|
32
41
|
```bash
|
|
33
|
-
nb
|
|
34
|
-
nb
|
|
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
|
-
|
|
47
|
+
For Caddy:
|
|
38
48
|
|
|
39
49
|
```bash
|
|
40
|
-
nb
|
|
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
|
-
|
|
55
|
+
The roles are:
|
|
44
56
|
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
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
|
|
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
|
-
|
|
52
|
-
|
|
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
|
-
|
|
80
|
+
Caddy uses the same action set, but with a different provider implementation.
|
|
56
81
|
|
|
57
|
-
## What the CLI
|
|
82
|
+
## What the CLI maintains
|
|
58
83
|
|
|
59
|
-
The CLI does more than
|
|
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
|
|
62
|
-
- 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`
|
|
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
|
|
75
|
-
| Get HTTPS running quickly
|
|
76
|
-
|
|
|
77
|
-
|
|
|
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
|
|
104
|
+
## When the CLI path is not the right fit
|
|
83
105
|
|
|
84
|
-
|
|
106
|
+
In these cases, the handwritten-config sections in the provider-specific pages are usually a better fit:
|
|
85
107
|
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
-
|
|
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
|
|
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
|
-
- [
|
|
100
|
-
- [Install with CLI
|
|
118
|
+
- [Environment variables](../../installation/env.md)
|
|
119
|
+
- [Install with the CLI](../../installation/cli.md)
|
|
@@ -1,166 +1,263 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Nginx"
|
|
3
|
+
description: "Use nb proxy nginx to generate and manage Nginx reverse-proxy configuration for CLI-managed NocoBase envs."
|
|
4
|
+
keywords: "NocoBase,nb proxy nginx,reverse proxy,Nginx,production"
|
|
5
|
+
---
|
|
6
|
+
|
|
1
7
|
# Nginx
|
|
2
8
|
|
|
3
|
-
If you already use Nginx on the server to manage sites, or you still want to manage certificates, caching,
|
|
9
|
+
If you already use Nginx on the server to manage sites, or you still want to manage certificates, caching, and access control yourself, `nb proxy nginx` is the recommended path.
|
|
10
|
+
|
|
11
|
+
If your goal is simply to get HTTPS working as quickly as possible and you do not want to maintain many proxy details yourself, [Caddy](./caddy.md) is usually the simpler option. But if Nginx is already part of your server setup, this page is the default path.
|
|
4
12
|
|
|
5
|
-
|
|
13
|
+
## When Nginx is the better fit
|
|
6
14
|
|
|
7
|
-
|
|
15
|
+
In practice, Nginx is usually the better choice when:
|
|
8
16
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
17
|
+
- you already use Nginx to manage multiple sites on the same server
|
|
18
|
+
- you still need to maintain certificates, caching, access control, or more custom rules yourself
|
|
19
|
+
- you want the entry layer to stay aligned with your existing Nginx operations workflow
|
|
11
20
|
|
|
12
|
-
|
|
21
|
+
If the only goal is to get HTTPS online quickly with less TLS work, [Caddy](./caddy.md) is usually the simpler route.
|
|
13
22
|
|
|
14
|
-
|
|
15
|
-
- If the app is not managed by the CLI, or you explicitly want to maintain the full Nginx config yourself, handwrite the `server` block
|
|
23
|
+
## Recommended order: choose a driver, generate config, then start
|
|
16
24
|
|
|
17
|
-
|
|
25
|
+
For a CLI-managed env of type `local` or `docker`, the default order is:
|
|
18
26
|
|
|
19
|
-
|
|
27
|
+
```bash
|
|
28
|
+
nb proxy nginx use docker
|
|
29
|
+
nb proxy nginx generate --env test2 --host c.local.nocobase.com
|
|
30
|
+
nb proxy nginx start
|
|
31
|
+
```
|
|
20
32
|
|
|
21
|
-
|
|
33
|
+
Or with a local process:
|
|
22
34
|
|
|
23
35
|
```bash
|
|
24
|
-
nb
|
|
36
|
+
nb proxy nginx use local
|
|
37
|
+
nb proxy nginx generate --env test2 --host c.local.nocobase.com
|
|
38
|
+
nb proxy nginx start
|
|
25
39
|
```
|
|
26
40
|
|
|
27
|
-
|
|
41
|
+
Common follow-up commands are:
|
|
28
42
|
|
|
29
43
|
```bash
|
|
30
|
-
nb
|
|
44
|
+
nb proxy nginx current
|
|
45
|
+
nb proxy nginx status
|
|
46
|
+
nb proxy nginx info
|
|
47
|
+
nb proxy nginx reload
|
|
48
|
+
nb proxy nginx restart
|
|
49
|
+
nb proxy nginx stop
|
|
31
50
|
```
|
|
32
51
|
|
|
33
|
-
|
|
52
|
+
In most cases:
|
|
53
|
+
|
|
54
|
+
- `current` is the quickest way to confirm the active runtime driver
|
|
55
|
+
- `status` shows whether Nginx 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
|
|
59
|
+
|
|
60
|
+
## What `generate` needs as input
|
|
61
|
+
|
|
62
|
+
The most common form is:
|
|
34
63
|
|
|
35
64
|
```bash
|
|
36
|
-
nb
|
|
37
|
-
nb env proxy nginx --env demo --host demo.example.com --port 8080
|
|
65
|
+
nb proxy nginx generate --env test2 --host c.local.nocobase.com
|
|
38
66
|
```
|
|
39
67
|
|
|
40
|
-
|
|
68
|
+
If you also want to specify the entry port:
|
|
41
69
|
|
|
42
|
-
|
|
70
|
+
```bash
|
|
71
|
+
nb proxy nginx generate --env test2 --host c.local.nocobase.com --port 8080
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Where:
|
|
75
|
+
|
|
76
|
+
- `--env`: which CLI env to generate config for
|
|
77
|
+
- `--host`: the public domain name
|
|
78
|
+
- `--port`: the proxy entry port, not the app's own `appPort`
|
|
43
79
|
|
|
44
|
-
The
|
|
80
|
+
The upstream application port comes from the saved `appPort` of that env. If the command says the env is missing `appPort`, save it first with:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
nb env update test2 --app-port 56575
|
|
84
|
+
```
|
|
45
85
|
|
|
46
|
-
|
|
86
|
+
If you later change settings such as `app-port` or `app-public-path` that affect proxy behavior, rerun `generate`.
|
|
87
|
+
|
|
88
|
+
## Files maintained by the CLI
|
|
89
|
+
|
|
90
|
+
Using `test2` as an example, the Nginx workflow usually maintains:
|
|
91
|
+
|
|
92
|
+
| Path | Purpose |
|
|
47
93
|
| --- | --- |
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
94
|
+
| `NB_CLI_ROOT/.nocobase/proxy/nginx/snippets` | Shared Nginx snippets directory |
|
|
95
|
+
| `NB_CLI_ROOT/.nocobase/proxy/nginx/test2/app.conf` | Editable site entry config |
|
|
96
|
+
| `NB_CLI_ROOT/.nocobase/proxy/nginx/test2/public/index-v1.html` | v1 SPA fallback page |
|
|
97
|
+
| `NB_CLI_ROOT/.nocobase/proxy/nginx/test2/public/index-v2.html` | v2 SPA fallback page |
|
|
98
|
+
| `NB_CLI_ROOT/test2/storage/dist-client` | Frontend build output for the current app |
|
|
99
|
+
| `NB_CLI_ROOT/test2/storage/uploads` | Uploads directory for the current app |
|
|
53
100
|
|
|
54
101
|
Where:
|
|
55
102
|
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
- `
|
|
59
|
-
-
|
|
103
|
+
- files under `NB_CLI_ROOT/.nocobase/proxy/nginx/...` are CLI-managed proxy helper files
|
|
104
|
+
- files under `NB_CLI_ROOT/test2/storage/...` belong to the application itself
|
|
105
|
+
- `app.conf` can be edited, but the NocoBase-managed block must stay intact
|
|
106
|
+
- `index-v1.html` and `index-v2.html` are rewritten according to the current env's subpath, active client version, and `CDN_BASE_URL`
|
|
60
107
|
|
|
61
108
|
:::warning Note
|
|
62
109
|
|
|
63
|
-
If you need
|
|
110
|
+
If you need site-level Nginx config such as rate limiting, extra headers, or access control, edit `app.conf`. The CLI-managed helper files are updated again when you regenerate the config.
|
|
64
111
|
|
|
65
112
|
:::
|
|
66
113
|
|
|
67
|
-
|
|
114
|
+
## Handwritten config: when you are not using the CLI
|
|
68
115
|
|
|
69
|
-
If
|
|
116
|
+
If the app is not CLI-managed, or you intentionally want to maintain the complete Nginx config yourself, you can still write it by hand.
|
|
70
117
|
|
|
71
|
-
|
|
72
|
-
nb env proxy nginx --env demo --host demo.example.com --install --reload
|
|
73
|
-
```
|
|
118
|
+
For NocoBase, though, a production reverse proxy is usually more than a single `proxy_pass`. In addition to forwarding API requests to the backend app, a complete config usually needs to handle uploads, frontend assets, WebSocket, `.well-known` routes, and SPA fallback pages together.
|
|
74
119
|
|
|
75
|
-
|
|
120
|
+
Using `test2` as the example, these are the key Nginx-related files and directories:
|
|
76
121
|
|
|
77
|
-
-
|
|
78
|
-
-
|
|
122
|
+
- Nginx snippets: `NB_CLI_ROOT/.nocobase/proxy/nginx/snippets`
|
|
123
|
+
- Editable entry config: `NB_CLI_ROOT/.nocobase/proxy/nginx/test2/app.conf`
|
|
124
|
+
- SPA fallback page for v1: `NB_CLI_ROOT/.nocobase/proxy/nginx/test2/public/index-v1.html`
|
|
125
|
+
- SPA fallback page for v2: `NB_CLI_ROOT/.nocobase/proxy/nginx/test2/public/index-v2.html`
|
|
126
|
+
- Frontend build output: `NB_CLI_ROOT/test2/storage/dist-client`
|
|
127
|
+
- Uploads directory: `NB_CLI_ROOT/test2/storage/uploads`
|
|
79
128
|
|
|
80
|
-
|
|
129
|
+
In other words, a handwritten config usually needs to cover at least these entry areas:
|
|
81
130
|
|
|
82
|
-
|
|
83
|
-
|
|
131
|
+
- `uploads`
|
|
132
|
+
- `dist`
|
|
133
|
+
- `well-known`
|
|
134
|
+
- `api`
|
|
135
|
+
- `ws`
|
|
136
|
+
- `spa`
|
|
137
|
+
|
|
138
|
+
So a complete Nginx config is usually more than a generic reverse proxy such as:
|
|
139
|
+
|
|
140
|
+
```nginx
|
|
141
|
+
location / {
|
|
142
|
+
proxy_pass http://127.0.0.1:13000;
|
|
143
|
+
}
|
|
84
144
|
```
|
|
85
145
|
|
|
86
|
-
|
|
146
|
+
For a CLI-managed app such as `test2`, a more realistic deployment structure usually looks closer to this:
|
|
87
147
|
|
|
88
|
-
|
|
148
|
+
```nginx
|
|
149
|
+
server {
|
|
150
|
+
listen 80;
|
|
151
|
+
server_name c.local.nocobase.com;
|
|
89
152
|
|
|
90
|
-
|
|
153
|
+
# Add custom directives or locations above the managed block as needed.
|
|
91
154
|
|
|
92
|
-
|
|
93
|
-
nb config set proxy.nb-cli-root /workspace
|
|
94
|
-
nb env proxy nginx --env demo --install --reload
|
|
95
|
-
```
|
|
155
|
+
client_max_body_size 0;
|
|
96
156
|
|
|
97
|
-
|
|
157
|
+
include NB_CLI_ROOT/.nocobase/proxy/nginx/snippets/mime-types.conf;
|
|
158
|
+
include NB_CLI_ROOT/.nocobase/proxy/nginx/snippets/gzip.conf;
|
|
98
159
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
160
|
+
location /storage/uploads/ {
|
|
161
|
+
alias NB_CLI_ROOT/test2/storage/uploads/;
|
|
162
|
+
include NB_CLI_ROOT/.nocobase/proxy/nginx/snippets/uploads-location.conf;
|
|
163
|
+
}
|
|
102
164
|
|
|
103
|
-
|
|
165
|
+
location ^~ /dist/ {
|
|
166
|
+
alias NB_CLI_ROOT/test2/storage/dist-client/;
|
|
167
|
+
include NB_CLI_ROOT/.nocobase/proxy/nginx/snippets/dist-location.conf;
|
|
168
|
+
}
|
|
104
169
|
|
|
105
|
-
|
|
170
|
+
location ~ ^/\\.well-known/(?<well_known>oauth-authorization-server|openid-configuration)/(?<resource_path>.+)$ {
|
|
171
|
+
rewrite ^ /$resource_path/.well-known/$well_known break;
|
|
172
|
+
proxy_pass http://127.0.0.1:56575;
|
|
173
|
+
include NB_CLI_ROOT/.nocobase/proxy/nginx/snippets/proxy-location.conf;
|
|
174
|
+
}
|
|
106
175
|
|
|
107
|
-
|
|
176
|
+
location ^~ /api/ {
|
|
177
|
+
proxy_pass http://127.0.0.1:56575;
|
|
178
|
+
include NB_CLI_ROOT/.nocobase/proxy/nginx/snippets/proxy-location.conf;
|
|
179
|
+
}
|
|
108
180
|
|
|
109
|
-
|
|
181
|
+
location = /ws {
|
|
182
|
+
proxy_pass http://127.0.0.1:56575;
|
|
183
|
+
include NB_CLI_ROOT/.nocobase/proxy/nginx/snippets/proxy-location.conf;
|
|
184
|
+
}
|
|
110
185
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
proxy_set_header Upgrade $http_upgrade;
|
|
126
|
-
proxy_set_header Connection "upgrade";
|
|
186
|
+
location = /v {
|
|
187
|
+
return 302 /v/$is_args$args;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
location ^~ /v/ {
|
|
191
|
+
alias NB_CLI_ROOT/.nocobase/proxy/nginx/test2/public/;
|
|
192
|
+
try_files $uri /index-v2.html =404;
|
|
193
|
+
include NB_CLI_ROOT/.nocobase/proxy/nginx/snippets/spa-location.conf;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
location ^~ / {
|
|
197
|
+
alias NB_CLI_ROOT/.nocobase/proxy/nginx/test2/public/;
|
|
198
|
+
try_files $uri /index-v1.html =404;
|
|
199
|
+
include NB_CLI_ROOT/.nocobase/proxy/nginx/snippets/spa-location.conf;
|
|
127
200
|
}
|
|
201
|
+
|
|
202
|
+
# Add custom directives or locations below the managed block as needed.
|
|
128
203
|
}
|
|
129
204
|
```
|
|
130
205
|
|
|
131
|
-
|
|
206
|
+
Two details matter here:
|
|
207
|
+
|
|
208
|
+
- files under `NB_CLI_ROOT/.nocobase/proxy/nginx/...` are CLI-managed proxy helper files
|
|
209
|
+
- files under `NB_CLI_ROOT/test2/storage/...` belong to the application's own build output and uploads
|
|
210
|
+
|
|
211
|
+
If the app uses subpath deployment, or if frontend assets, uploads, and the reverse proxy 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:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
nb proxy nginx generate --env test2 --host c.local.nocobase.com
|
|
215
|
+
```
|
|
132
216
|
|
|
133
|
-
|
|
134
|
-
- Replace `127.0.0.1:13000` with the real address your NocoBase app listens on
|
|
135
|
-
- Adjust `client_max_body_size` to match your upload needs
|
|
217
|
+
Then use the generated result as the baseline for manual adjustments.
|
|
136
218
|
|
|
137
|
-
|
|
219
|
+
The safer workflow is usually:
|
|
220
|
+
|
|
221
|
+
1. let the CLI generate the Nginx config first
|
|
222
|
+
2. use the generated output to confirm the routing structure and real filesystem paths
|
|
223
|
+
3. then adjust it for your own domain, runtime driver, and mount layout
|
|
224
|
+
|
|
225
|
+
That is usually less error-prone than writing the full config from scratch.
|
|
138
226
|
|
|
139
227
|
## Validate and reload the config
|
|
140
228
|
|
|
229
|
+
If you write or adjust Nginx config manually, validate it first and then reload:
|
|
230
|
+
|
|
141
231
|
```bash
|
|
142
232
|
nginx -t
|
|
143
233
|
systemctl reload nginx
|
|
144
234
|
```
|
|
145
235
|
|
|
146
|
-
If you
|
|
236
|
+
If you are not using `systemd` to manage Nginx, replace that with your own reload workflow.
|
|
237
|
+
|
|
238
|
+
If you manage the entry layer through `nb proxy nginx`, the usual first choice is:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
nb proxy nginx reload
|
|
242
|
+
```
|
|
147
243
|
|
|
148
244
|
## How to handle HTTPS
|
|
149
245
|
|
|
150
|
-
If you have already decided to
|
|
246
|
+
If you have already decided to keep using Nginx, you can keep HTTPS there as well. A common pattern is to extend `listen 80` into a `80/443` setup and then add certificate paths and TLS settings.
|
|
151
247
|
|
|
152
|
-
|
|
248
|
+
If the goal is simply to get usable HTTPS quickly without managing certificate issuance and renewal yourself, switching to [Caddy](./caddy.md) is usually simpler.
|
|
153
249
|
|
|
154
|
-
##
|
|
250
|
+
## Common notes
|
|
155
251
|
|
|
156
|
-
- `nb
|
|
157
|
-
-
|
|
158
|
-
-
|
|
159
|
-
-
|
|
252
|
+
- `nb proxy nginx generate` only works for CLI-managed envs whose runtime is reachable from the current machine, which means `local` or `docker`
|
|
253
|
+
- if the command says the env is missing `appPort`, run `nb env update <name> --app-port <port>` first
|
|
254
|
+
- if you already have a large top-level Nginx config, the CLI-generated config is usually better used as a site fragment than as a replacement for the entire main config
|
|
255
|
+
- if you later change settings such as `app-port` or `app-public-path` that affect proxy behavior, rerun `generate`
|
|
160
256
|
|
|
161
257
|
## Related links
|
|
162
258
|
|
|
163
|
-
- [
|
|
164
|
-
- [
|
|
259
|
+
- [Reverse Proxy in Production](./index.md)
|
|
260
|
+
- [Caddy](./caddy.md)
|
|
261
|
+
- [Install with the CLI](../../installation/cli.md)
|
|
165
262
|
- [Install with Docker Compose](../../installation/docker-compose.md)
|
|
166
|
-
- [
|
|
263
|
+
- [Environment variables](../../installation/env.md)
|