@lobehub/lobehub 2.0.3 → 2.0.5

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 (87) hide show
  1. package/.github/ISSUE_TEMPLATE/1_bug_report.yml +0 -11
  2. package/CHANGELOG.md +50 -0
  3. package/README.md +9 -13
  4. package/README.zh-CN.md +6 -8
  5. package/apps/desktop/Development.md +1 -1
  6. package/changelog/v2.json +18 -0
  7. package/docker-compose/local/docker-compose.yml +2 -2
  8. package/docker-compose/local/grafana/docker-compose.yml +3 -3
  9. package/docker-compose/local/logto/docker-compose.yml +3 -4
  10. package/docker-compose/local/zitadel/.env.example +3 -4
  11. package/docker-compose/local/zitadel/.env.zh-CN.example +1 -2
  12. package/docker-compose/local/zitadel/docker-compose.yml +3 -3
  13. package/docker-compose/production/grafana/docker-compose.yml +3 -3
  14. package/docker-compose/production/logto/.env.example +7 -9
  15. package/docker-compose/production/logto/.env.zh-CN.example +7 -9
  16. package/docker-compose/production/logto/docker-compose.yml +3 -3
  17. package/docker-compose/production/zitadel/.env.example +4 -6
  18. package/docker-compose/production/zitadel/.env.zh-CN.example +3 -5
  19. package/docker-compose/production/zitadel/docker-compose.yml +3 -3
  20. package/docs/development/basic/folder-structure.mdx +1 -2
  21. package/docs/development/basic/folder-structure.zh-CN.mdx +1 -2
  22. package/docs/self-hosting/advanced/auth/legacy.mdx +1 -1
  23. package/docs/self-hosting/advanced/auth/legacy.zh-CN.mdx +1 -1
  24. package/docs/self-hosting/advanced/auth/nextauth-to-betterauth.mdx +4 -0
  25. package/docs/self-hosting/advanced/auth/nextauth-to-betterauth.zh-CN.mdx +4 -0
  26. package/docs/self-hosting/advanced/auth/providers/casdoor.mdx +8 -0
  27. package/docs/self-hosting/advanced/auth/providers/casdoor.zh-CN.mdx +8 -0
  28. package/docs/self-hosting/advanced/auth.mdx +28 -1
  29. package/docs/self-hosting/advanced/auth.zh-CN.mdx +29 -2
  30. package/docs/self-hosting/advanced/upstream-sync.mdx +5 -5
  31. package/docs/self-hosting/advanced/upstream-sync.zh-CN.mdx +5 -5
  32. package/docs/self-hosting/environment-variables/auth.mdx +2 -334
  33. package/docs/self-hosting/environment-variables/auth.zh-CN.mdx +2 -307
  34. package/docs/self-hosting/environment-variables/basic.mdx +1 -1
  35. package/docs/self-hosting/environment-variables/basic.zh-CN.mdx +1 -1
  36. package/docs/self-hosting/environment-variables.mdx +1 -1
  37. package/docs/self-hosting/platform/docker-compose.mdx +837 -90
  38. package/docs/self-hosting/platform/docker-compose.zh-CN.mdx +809 -84
  39. package/docs/self-hosting/platform/docker.mdx +110 -111
  40. package/docs/self-hosting/platform/docker.zh-CN.mdx +103 -151
  41. package/docs/self-hosting/{server-database → platform}/dokploy.mdx +2 -2
  42. package/docs/self-hosting/{server-database → platform}/dokploy.zh-CN.mdx +2 -2
  43. package/docs/self-hosting/platform/repocloud.mdx +11 -10
  44. package/docs/self-hosting/platform/repocloud.zh-CN.mdx +13 -11
  45. package/docs/self-hosting/platform/sealos.mdx +79 -13
  46. package/docs/self-hosting/platform/sealos.zh-CN.mdx +92 -11
  47. package/docs/self-hosting/platform/vercel.mdx +323 -19
  48. package/docs/self-hosting/platform/vercel.zh-CN.mdx +318 -24
  49. package/docs/self-hosting/platform/zeabur.mdx +41 -37
  50. package/docs/self-hosting/platform/zeabur.zh-CN.mdx +34 -39
  51. package/docs/self-hosting/server-database.mdx +6 -6
  52. package/docs/self-hosting/server-database.zh-CN.mdx +5 -5
  53. package/package.json +1 -1
  54. package/packages/types/src/user/preference.ts +2 -2
  55. package/scripts/_shared/checkDeprecatedAuth.js +16 -0
  56. package/src/libs/next/proxy/createRouteMatcher.test.ts +0 -8
  57. package/src/libs/trpc/middleware/userAuth.test.ts +0 -6
  58. package/src/proxy.ts +0 -1
  59. package/src/server/routers/async/__tests__/caller.test.ts +2 -2
  60. package/src/server/routers/lambda/config/index.test.ts +0 -6
  61. package/src/tools/artifacts/systemRole.ts +84 -120
  62. package/docs/self-hosting/platform/alibaba-cloud.mdx +0 -28
  63. package/docs/self-hosting/platform/alibaba-cloud.zh-CN.mdx +0 -25
  64. package/docs/self-hosting/platform/btpanel.mdx +0 -48
  65. package/docs/self-hosting/platform/btpanel.zh-CN.mdx +0 -51
  66. package/docs/self-hosting/platform/netlify.mdx +0 -91
  67. package/docs/self-hosting/platform/netlify.zh-CN.mdx +0 -86
  68. package/docs/self-hosting/platform/railway.mdx +0 -29
  69. package/docs/self-hosting/platform/railway.zh-CN.mdx +0 -29
  70. package/docs/self-hosting/platform/tencentcloud-lighthouse.mdx +0 -29
  71. package/docs/self-hosting/platform/tencentcloud-lighthouse.zh-CN.mdx +0 -26
  72. package/docs/self-hosting/server-database/docker-compose.mdx +0 -879
  73. package/docs/self-hosting/server-database/docker-compose.zh-CN.mdx +0 -854
  74. package/docs/self-hosting/server-database/docker.mdx +0 -154
  75. package/docs/self-hosting/server-database/docker.zh-CN.mdx +0 -153
  76. package/docs/self-hosting/server-database/netlify.mdx +0 -13
  77. package/docs/self-hosting/server-database/netlify.zh-CN.mdx +0 -16
  78. package/docs/self-hosting/server-database/railway.mdx +0 -13
  79. package/docs/self-hosting/server-database/railway.zh-CN.mdx +0 -15
  80. package/docs/self-hosting/server-database/repocloud.mdx +0 -33
  81. package/docs/self-hosting/server-database/repocloud.zh-CN.mdx +0 -32
  82. package/docs/self-hosting/server-database/sealos.mdx +0 -97
  83. package/docs/self-hosting/server-database/sealos.zh-CN.mdx +0 -112
  84. package/docs/self-hosting/server-database/vercel.mdx +0 -344
  85. package/docs/self-hosting/server-database/vercel.zh-CN.mdx +0 -337
  86. package/docs/self-hosting/server-database/zeabur.mdx +0 -76
  87. package/docs/self-hosting/server-database/zeabur.zh-CN.mdx +0 -67
@@ -1,879 +0,0 @@
1
- ---
2
- title: Deploying LobeHub with Docker Compose
3
- description: >-
4
- Learn how to deploy the LobeHub service using Docker Compose, including
5
- configuration tutorials for various services.
6
- tags:
7
- - Docker Compose
8
- - LobeHub
9
- - Docker Container
10
- - Deployment Guide
11
- ---
12
-
13
- # Deploying LobeHub Server Database Version with Docker Compose
14
-
15
- <div style={{display:"flex", gap: 4}}>
16
- [![][docker-release-shield]][docker-release-link]
17
-
18
- [![][docker-size-shield]][docker-size-link]
19
-
20
- [![][docker-pulls-shield]][docker-pulls-link]
21
- </div>
22
-
23
- ## Quick Start
24
-
25
- <Callout type="info">
26
- **System Compatibility Notes**
27
-
28
- - One-click deployment is supported in Unix environments (Linux/macOS).
29
-
30
- - Windows users must run through [WSL 2](https://aka.ms/wsl).
31
-
32
- - The one-click startup script is only for initial deployment; for subsequent deployments, please refer to the [Custom Deployment](#custom-deployment) section.
33
-
34
- - Port occupation check: Ensure that ports `3210`, `8000`, `9000`, and `9001` are available.
35
- </Callout>
36
-
37
- Execute the following commands to set up the deployment environment; the directory `lobe-chat-db` will be used to store your configuration files and subsequent database files.
38
-
39
- ```sh
40
- mkdir lobe-chat-db && cd lobe-chat-db
41
- ```
42
-
43
- Fetch and execute the deployment script:
44
-
45
- ```sh
46
- bash <(curl -fsSL https://lobe.li/setup.sh) -l en
47
- ```
48
-
49
- The script supports the following deployment modes; please choose the appropriate mode based on your needs and read the rest of the documentation.
50
-
51
- - [Local Mode (default)](#local-mode): Accessible only locally, not supporting LAN/public access; suitable for initial experiences.
52
- - [Port Mode](#port-mode): Supports LAN/public `http` access; suitable for no domain or private network use.
53
- - [Domain Mode](#domain-mode): Supports LAN/public `http/https` access with reverse proxy; suitable for personal or team use.
54
-
55
- <Callout type="info">
56
- In the script's options prompt `(Option1/Option2)[Option1]`: `(Option1 / Option2)` indicates
57
- selectable options, while `[Option1]` indicates the default option; simply press enter to choose
58
- the default.
59
- </Callout>
60
-
61
- ### Local Mode
62
-
63
- <Steps>
64
- ### Complete Remaining Configuration in Interactive Script
65
-
66
- Continue pressing enter to use the default configuration.
67
-
68
- ### Check Configuration Generation Report
69
-
70
- After the script finishes running, you need to check the configuration generation report, which includes the accounts and initial login passwords for the Casdoor administrator and user.
71
-
72
- <Callout type="warning">
73
- Please log in to LobeHub using the user account; the administrator account is only for managing
74
- Casdoor.
75
- </Callout>
76
-
77
- ```log
78
- The results of the secure key generation are as follows:
79
- LobeHub:
80
- - URL: http://localhost:3210
81
- - Username: user
82
- - Password: c66f8c
83
- Casdoor:
84
- - URL: http://localhost:8000
85
- - Username: admin
86
- - Password: c66f8c
87
- Minio:
88
- - URL: http://localhost:9000
89
- - Username: admin
90
- - Password: 8c82ea41
91
- ```
92
-
93
- ### Start Docker
94
-
95
- ```sh
96
- docker compose up -d
97
- ```
98
-
99
- ### Check Logs
100
-
101
- ```sh
102
- docker logs -f lobe-chat
103
- ```
104
-
105
- If you see the following logs in the container, it means the startup was successful:
106
-
107
- ```log
108
- [Database] Start to migration...
109
- ✅ database migration pass.
110
- -------------------------------------
111
- ▲ Next.js 14.x.x
112
- - Local: http://localhost:3210
113
- - Network: http://0.0.0.0:3210
114
-
115
- ✓ Starting...
116
- ✓ Ready in 95ms
117
- ```
118
-
119
- ### Access Application
120
-
121
- Visit your LobeHub service at [http://localhost:3210](http://localhost:3210). The account credentials for the application can be found in the report from step `2`.
122
- </Steps>
123
-
124
- ### Port Mode
125
-
126
- <Steps>
127
- ### Complete Remaining Configuration in Interactive Script
128
-
129
- In port mode, you need to complete the following based on the script prompts:
130
-
131
- - Server IP address settings: for LAN/public access.
132
- - Regenerate secure keys: We highly recommend regenerating the secure keys; if you lack the key generation library required by the script, we suggest referring to the [Custom Deployment](#custom-deployment) section for key modifications.
133
-
134
- ### Check Configuration Generation Report
135
-
136
- After the script finishes running, please check the configuration generation report for the Casdoor administrator account, user account, and their initial login passwords.
137
-
138
- <Callout type="warning">
139
- Please log in to LobeHub using the user account; the administrator account is only for managing
140
- Casdoor.
141
- </Callout>
142
-
143
- ```log
144
- The results of the secure key generation are as follows:
145
- LobeHub:
146
- - URL: http://your_server_ip:3210
147
- - Username: user
148
- - Password: 837e26
149
- Casdoor:
150
- - URL: http://your_server_ip:8000
151
- - Username: admin
152
- - Password: 837e26
153
- Minio:
154
- - URL: http://your_server_ip:9000
155
- - Username: admin
156
- - Password: dbac8440
157
- ```
158
-
159
- ### Start Docker
160
-
161
- ```sh
162
- docker compose up -d
163
- ```
164
-
165
- ### Check Logs
166
-
167
- ```sh
168
- docker logs -f lobe-chat
169
- ```
170
-
171
- If you see the following logs in the container, it means the startup was successful:
172
-
173
- ```log
174
- [Database] Start to migration...
175
- ✅ database migration pass.
176
- -------------------------------------
177
- ▲ Next.js 14.x.x
178
- - Local: http://your_server_ip:3210
179
- - Network: http://0.0.0.0:3210
180
- ✓ Starting...
181
- ✓ Ready in 95ms
182
- ```
183
-
184
- ### Access Application
185
-
186
- You can access your LobeHub service at `http://your_server_ip:3210`. The account credentials for the application can be found in the report from step `2`.
187
-
188
- <Callout type="warning">
189
- If your service can accessed via the public network,
190
- we strongly recommend disabling the registration,
191
- refer to the [documentation](https://lobehub.com/docs/self-hosting/advanced/auth/next-auth/casdoor)
192
- for more information.
193
- </Callout>
194
- </Steps>
195
-
196
- ### Domain Mode
197
-
198
- <Steps>
199
- ### Complete Reverse Proxy Configuration
200
-
201
- In domain mode, you need to complete the reverse proxy configuration and ensure that the LAN/public can access the following services. Please use a reverse proxy to map the following service ports to the domain names:
202
-
203
- | Domain | Proxy Port | Required |
204
- | ---------------------- | ---------- | -------- |
205
- | `lobe.example.com` | `3210` | Yes |
206
- | `auth.example.com` | `8000` | Yes |
207
- | `minio.example.com` | `9000` | Yes |
208
- | `minio-ui.example.com` | `9001` | |
209
-
210
- <Callout type="important">
211
- If you are using panel software like [aaPanel](https://www.bt.cn/) for reverse proxy configuration,
212
- ensure it does not intercept requests to the `.well-known` path to facilitate the proper functioning of Casdoor's OAuth2 configuration.
213
- Below is a whitelist configuration for the Nginx server block concerning paths for Casdoor reverse proxy:
214
-
215
- ```nginx
216
- location /.well-known/openid-configuration {
217
- proxy_pass http://localhost:8000; # Forward to localhost:8000
218
- proxy_set_header Host $host; # Keep the original host header
219
- proxy_set_header X-Real-IP $remote_addr; # Keep the client's real IP
220
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Keep the forwarded IP
221
- proxy_set_header X-Forwarded-Proto $scheme; # Keep the request protocol
222
- }
223
- ```
224
-
225
- ⚠️ If you are using such panel software,
226
- please do not enable any form of caching in the reverse proxy settings of such panel software to avoid affecting the normal operation of the service.
227
- Read more at [https://github.com/lobehub/lobe-chat/discussions/5986](https://github.com/lobehub/lobe-chat/discussions/5986)
228
- </Callout>
229
-
230
- ### Complete Remaining Configuration in Interactive Script
231
-
232
- In domain mode, you need to complete the following configurations based on script prompts:
233
-
234
- - Domain setup for the LobeHub service: `lobe.example.com`
235
- - Domain setup for the Minio service: `minio.example.com`
236
- - Domain setup for the Casdoor service: `auth.example.com`
237
- - Choose the access protocol: `http` or `https`
238
- - Regenerate secure keys: We highly recommend regenerating the secure keys; if you lack the key generation library required by the script, we suggest referring to the [Custom Deployment](#custom-deployment) section for key modifications.
239
-
240
- <Callout type="warning">
241
- The following issues may impede access to your service:
242
-
243
- - The domain configuration here must match the reverse proxy configuration in step `1`.
244
-
245
- - If you are using Cloudflare for domain resolution and have activated `full proxy`, please use the `https` protocol.
246
-
247
- - If you have used the HTTPS protocol, ensure that your domain certificate is correctly configured; one-click deployment does not support self-signed certificates by default.
248
- </Callout>
249
-
250
- ### Check Configuration Generation Report
251
-
252
- After the script finishes running, you need to check the configuration generation report, which includes the initial login password for the Casdoor administrator.
253
-
254
- <Callout type="warning">
255
- Please log in to LobeHub using the user account; the administrator account is only for managing
256
- Casdoor.
257
- </Callout>
258
-
259
- ```log
260
- The results of the secure key generation are as follows:
261
- LobeHub:
262
- - URL: https://lobe.example.com
263
- - Username: user
264
- - Password: 837e26
265
- Casdoor:
266
- - URL: https://auth.example.com
267
- - Username: admin
268
- - Password: 837e26
269
- Minio:
270
- - URL: https://minio.example.com
271
- - Username: admin
272
- - Password: dbac8440
273
- ```
274
-
275
- ### Start Docker
276
-
277
- ```sh
278
- docker compose up -d
279
- ```
280
-
281
- ### Check Logs
282
-
283
- ```sh
284
- docker logs -f lobe-chat
285
- ```
286
-
287
- If you see the following logs in the container, it indicates a successful startup:
288
-
289
- ```log
290
- [Database] Start to migration...
291
- ✅ database migration pass.
292
- -------------------------------------
293
- ▲ Next.js 14.x.x
294
- - Local: https://localhost:3210
295
- - Network: http://0.0.0.0:3210
296
- ✓ Starting...
297
- ✓ Ready in 95ms
298
- ```
299
-
300
- ### Access Application
301
-
302
- You can access your LobeHub service via `https://lobe.example.com`. The account credentials for the application can be found in the report from step `3`.
303
-
304
- <Callout type="warning">
305
- If your service can accessed via the public network,
306
- we strongly recommend disabling the registration,
307
- refer to the [documentation](https://lobehub.com/docs/self-hosting/advanced/auth/next-auth/casdoor)
308
- for more information.
309
- </Callout>
310
- </Steps>
311
-
312
- ## Custom Deployment
313
-
314
- This section mainly introduces the configurations that need to be modified to customize the deployment of the LobeHub service in different network environments. Before starting, you can download the [Docker Compose configuration file](https://raw.githubusercontent.com/lobehub/lobe-chat/HEAD/docker-compose/local/docker-compose.yml) and the [environment variable configuration file](https://raw.githubusercontent.com/lobehub/lobe-chat/refs/heads/main/docker-compose/local/.env.example).
315
-
316
- ```sh
317
- curl -O https://raw.githubusercontent.com/lobehub/lobe-chat/HEAD/docker-compose/local/docker-compose.yml
318
- curl -O https://raw.githubusercontent.com/lobehub/lobe-chat/HEAD/docker-compose/local/.env.example
319
- mv .env.example .env
320
- ```
321
-
322
- <Callout type="info">
323
- This section does not cover all complete variables; remaining variables can be referenced in
324
- [Deploying with the Server Database](/en/docs/self-hosting/server-database).
325
- </Callout>
326
-
327
- ### Prerequisites
328
-
329
- Generally, to fully run the LobeHub database version, you will need at least the following four services:
330
-
331
- - The LobeHub database version itself
332
- - PostgreSQL database with PGVector plugin
333
- - Object storage service that supports S3 protocol
334
- - An SSO authentication service supported by LobeHub
335
-
336
- These services can be combined through self-hosting or online cloud services to meet various deployment needs. In this article, we provide a Docker Compose configuration entirely based on open-source self-hosted services, which can be used directly to start the LobeHub database version or modified to suit your requirements.
337
-
338
- We use [MinIO](https://github.com/minio/minio) as the local S3 object storage service and [Casdoor](https://github.com/casdoor/casdoor) as the local authentication service by default.
339
-
340
- <Callout type="warning">
341
- If your network topology is complex, please make sure these services can communicate properly
342
- within your network environment.
343
- </Callout>
344
-
345
- ### Necessary Configuration
346
-
347
- Now, we will introduce the necessary configurations for running these services:
348
-
349
- 1. Casdoor
350
-
351
- - LobeHub requires communication with Casdoor, so you need to configure Casdoor's Issuer.
352
-
353
- ```env
354
- AUTH_CASDOOR_ISSUER=https://auth.example.com
355
- ```
356
-
357
- This configuration will affect LobeHub's login authentication service, and you need to ensure that the URL of the Casdoor service is correct. You can find common manifestations and solutions for errors in this configuration in the [FAQ](#faq).
358
-
359
- - Additionally, you need to allow the callback URL in Casdoor to point to the LobeHub address:
360
-
361
- Please add a line in the `Authentication -> Application` -> `<Application ID, default is app-built-in>` -> `Redirect URI` in Casdoor's web panel:
362
-
363
- ```
364
- https://auth.example.com/api/auth/callback/casdoor
365
- ```
366
-
367
- - Casdoor needs to provide the Origin information for access in the environment variables:
368
-
369
- ```env
370
- origin=https://auth.example.com
371
- ```
372
-
373
- 2. MinIO
374
-
375
- - LobeHub needs to provide a public access URL for object files for the LLM service provider, hence you need to configure MinIO's Endpoint.
376
-
377
- ```env
378
- S3_PUBLIC_DOMAIN=https://minio.example.com
379
- S3_ENDPOINT=https://minio.example.com
380
- ```
381
-
382
- 3. PostgreSQL
383
-
384
- This configuration is found in the `docker-compose.yml` file, and you will need to configure the database name and password:
385
-
386
- ```yaml
387
- services:
388
- lobe:
389
- environment:
390
- - 'DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@postgresql:5432/${LOBE_DB_NAME}'
391
- ```
392
-
393
- ## FAQ
394
-
395
- #### Unable to Log In Properly
396
-
397
- Check for the following errors based on the container logs:
398
-
399
- ```sh
400
- docker logs -f lobe-chat
401
- ```
402
-
403
- - r3: "response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)
404
-
405
- ```log
406
- lobe-chat | [auth][error] r3: "response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)
407
- ```
408
-
409
- Cause: This issue is typically caused by improper reverse proxy configuration; you need to ensure your reverse proxy configuration does not intercept the Casdoor OAuth2 configuration requests.
410
-
411
- Solutions:
412
-
413
- - Please refer to the reverse proxy configuration notes in the [Domain Mode](#domain-mode) section.
414
-
415
- - A direct troubleshooting method is to access `https://auth.example.com/.well-known/openid-configuration` directly; if:
416
-
417
- - Non-JSON format data is returned, it indicates your reverse proxy configuration is incorrect.
418
- - If the returned JSON format data contains an `"issuer": "URL"` field that does not match your configured `https://auth.example.com`, it indicates your environment variable configuration is incorrect.
419
-
420
- - TypeError: fetch failed
421
-
422
- ```log
423
- lobe-chat | [auth][error] TypeError: fetch failed
424
- ```
425
-
426
- Cause: LobeHub cannot access the authentication service.
427
-
428
- Solutions:
429
-
430
- - Check whether your authentication service is running properly and whether LobeHub's network can reach the authentication service.
431
-
432
- - A straightforward troubleshooting method is to use the `curl` command in the LobeHub container terminal to access your authentication service at `https://auth.example.com/.well-known/openid-configuration`. If JSON format data is returned, it indicates your authentication service is functioning correctly.
433
-
434
- #### OAuth Token Exchange Failures with Reverse Proxy
435
-
436
- If OAuth authentication fails during the token exchange phase when using Docker behind a reverse proxy, this is typically caused by the default `MIDDLEWARE_REWRITE_THROUGH_LOCAL=1` setting which rewrites URLs to `127.0.0.1:3210`.
437
-
438
- **Solution**: Set `MIDDLEWARE_REWRITE_THROUGH_LOCAL=0` in your `.env` file and restart Docker containers:
439
-
440
- ```bash
441
- docker compose down
442
- docker compose up -d
443
- ```
444
-
445
- ````markdown
446
- ## Extended Configuration
447
-
448
- To enhance your LobeHub service, you can perform the following extended configurations according to your needs.
449
-
450
- ### Use MinIO to Store Casdoor Avatars
451
-
452
- Allow users to change their avatars in Casdoor.
453
-
454
- 1. First, create a bucket named `casdoor` in `buckets`, select a custom policy, and copy and paste the content below (if you modify the bucket name, please find and replace accordingly).
455
-
456
- ```json
457
- {
458
- "Statement": [
459
- {
460
- "Effect": "Allow",
461
- "Principal": {
462
- "AWS": ["*"]
463
- },
464
- "Action": ["s3:GetBucketLocation"],
465
- "Resource": ["arn:aws:s3:::casdoor"]
466
- },
467
- {
468
- "Effect": "Allow",
469
- "Principal": {
470
- "AWS": ["*"]
471
- },
472
- "Action": ["s3:ListBucket"],
473
- "Resource": ["arn:aws:s3:::casdoor"],
474
- "Condition": {
475
- "StringEquals": {
476
- "s3:prefix": ["files/*"]
477
- }
478
- }
479
- },
480
- {
481
- "Effect": "Allow",
482
- "Principal": {
483
- "AWS": ["*"]
484
- },
485
- "Action": ["s3:PutObject", "s3:DeleteObject", "s3:GetObject"],
486
- "Resource": ["arn:aws:s3:::casdoor/**"]
487
- }
488
- ],
489
- "Version": "2012-10-17"
490
- }
491
- ```
492
- ````
493
-
494
- 2. Create a new access key and store the generated `Access Key` and `Secret Key`.
495
-
496
- 3. In Casdoor's `Authentication -> Providers`, associate the MinIO S3 service. Below is an example configuration:
497
-
498
- ![casdoor](/blog/assets18bb134dbc5792d6a624199cca8bf7d3.webp)
499
-
500
- Here, the client ID and client secret correspond to the `Access Key` and `Secret Key` from the previous step; replace `192.168.31.251` with `your_server_ip`.
501
-
502
- 4. In Casdoor's `Authentication -> Apps`, add a provider to the `app-built-in` application, select `minio`, and save and exit.
503
-
504
- 5. You can attempt to upload a file in Casdoor's `Authentication -> Resources` to test if the configuration is correct.
505
-
506
- ### Migrating from `logto` to `Casdoor` in Production Deployment
507
-
508
- This is applicable for users who have been using `logto` as their login and authentication service in a production environment.
509
-
510
- <Callout type="info">
511
- Due to significant instability when using [Logto](https://logto.io/) as a login and authentication
512
- service, the following tutorial is based on deploying with an IP mode, implementing a domain
513
- release solution using Casdoor as the authentication service provider. The remainder of this
514
- article will illustrate using this as an example. If you are using other login authentication
515
- services like Logto, the process should be similar, but be aware that port configurations may
516
- differ among different services.
517
- </Callout>
518
-
519
- In the following, it is assumed that in addition to the above services, you are also running an **Nginx** layer for reverse proxy and SSL configuration.
520
-
521
- The domain and corresponding service port descriptions are as follows:
522
-
523
- - `lobe.example.com`: This is your LobeHub service domain, which needs to reverse proxy to the LobeHub service port, default is `3210`.
524
- - `auth.example.com`: This is your Logto UI domain, which needs to reverse proxy to the Logto WebUI service port, default is `8000`.
525
- - `minio.example.com`: This is your MinIO API domain, which needs to reverse proxy to the MinIO API service port, default is `9000`.
526
- - `minio-ui.example.com`: Optional, this is your MinIO UI domain, which needs to reverse proxy to the MinIO WebUI service port, default is `9001`.
527
-
528
- #### Configuration File
529
-
530
- ```sh
531
- bash <(curl -fsSL https://raw.githubusercontent.com/lobehub/lobe-chat/HEAD/docker-compose/local/setup.sh) -f -l zh_CN
532
- docker compose up -d
533
- ```
534
-
535
- Make sure to save the newly generated password at this time!
536
-
537
- After running, you will get three files:
538
-
539
- - init\_data.json
540
- - docker-compose.yml
541
- - .env
542
-
543
- Next, modify the configuration files to achieve domain release.
544
-
545
- 1. Modify the `docker-compose.yml` file.
546
-
547
- 1. Change the `MINIO_API_CORS_ALLOW_ORIGIN` field of `minio`.
548
-
549
- ```yaml
550
- 'MINIO_API_CORS_ALLOW_ORIGIN=https://lobe.example.com'
551
- ```
552
-
553
- 2. Modify the `origin` field of `casdoor`.
554
-
555
- ```yaml
556
- origin: 'https://auth.example.com'
557
- ```
558
-
559
- 3. Modify the `environment` field of `lobe`.
560
-
561
- ```yaml
562
- # - 'APP_URL=http://localhost:3210'
563
- - 'APP_URL=https://lobe.example.com'
564
-
565
- - 'AUTH_SSO_PROVIDERS=casdoor'
566
- - 'KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ='
567
- - 'AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg'
568
- # - 'AUTH_URL=http://localhost:${LOBE_PORT}/api/auth'
569
- - 'AUTH_URL=https://lobe.example.com/api/auth'
570
-
571
- # - 'AUTH_CASDOOR_ISSUER=http://localhost:${CASDOOR_PORT}'
572
- - 'AUTH_CASDOOR_ISSUER=https://auth.example.com'
573
-
574
- - 'DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@postgresql:5432/${LOBE_DB_NAME}'
575
- # - 'S3_ENDPOINT=http://localhost:${MINIO_PORT}'
576
- - 'S3_ENDPOINT=https://minio.example.com'
577
-
578
- - 'S3_BUCKET=${MINIO_LOBE_BUCKET}'
579
- # - 'S3_PUBLIC_DOMAIN=http://localhost:${MINIO_PORT}'
580
- - 'S3_PUBLIC_DOMAIN=https://minio.example.com'
581
-
582
- - 'S3_ENABLE_PATH_STYLE=1'
583
- - 'LLM_VISION_IMAGE_USE_BASE64=1'
584
- ```
585
-
586
- 2. Modify the `.env` file.
587
-
588
- <Callout type="info">For security reasons, modify the ROOT USER field in the `.env` file.</Callout>
589
-
590
- ```sh
591
- # MinIO S3 configuration
592
- MINIO_ROOT_USER=XXXX
593
- MINIO_ROOT_PASSWORD=XXXX
594
- ```
595
-
596
- #### Postgres Database Configuration
597
-
598
- You can check the logs with the following command:
599
-
600
- ```sh
601
- docker logs -f lobe-chat
602
- ```
603
-
604
- <Callout type="tip">
605
- In our official Docker images, automatic migration of the database schema is performed before
606
- starting the images. Our official images guarantee the stability of "empty database -> complete
607
- tables" for automatic table creation. Therefore, we recommend your database instance use an empty
608
- table instance to avoid the trouble of manually maintaining table structure or migrations.
609
- </Callout>
610
-
611
- If you encounter issues during table creation, you can try the following command to forcibly remove the database container and restart:
612
-
613
- ```sh
614
- docker compose down # Stop the service
615
- sudo rm -rf ./data # Remove mounted database data
616
- docker compose up -d # Restart
617
- ```
618
-
619
- #### Login Authentication Service Configuration
620
-
621
- You first need to access the WebUI for configuration:
622
-
623
- - If you have set up the reverse proxy as mentioned before, open `https://auth.example.com`
624
- - Otherwise, after port mapping, open `http://localhost:8000`
625
-
626
- Log in to the admin account:
627
-
628
- - The default username is admin.
629
- - The default password is the random password generated when downloading the config file. If forgotten, you can find it in the `init_data.json` file.
630
-
631
- After logging in, perform the following actions:
632
-
633
- 1. In `User Management -> Organizations`, add a new organization with the name and display name `Lobe Users`. Keep the rest as default.
634
- 2. In `Authentication -> Apps`, add a new application.
635
-
636
- - Name and display name should be `LobeHub`.
637
- - Organization should be `Lobe Users`.
638
- - Add a line in Redirect URLs as `https://lobe.example.com/api/auth/callback/casdoor`.
639
- - Disable all login methods except password.
640
- - Fill in the client ID and client secret in the `.env` file under `AUTH_CASDOOR_ID` and `AUTH_CASDOOR_SECRET`.
641
- - (Optional) Design the appearance of the login and registration pages by mimicking the `built-in` application configuration.
642
- - Save and exit.
643
-
644
- <Callout type="info">
645
- Following the steps above ensures that not all users are administrators by default, leading to an
646
- unsafe situation.
647
- </Callout>
648
-
649
- #### S3 Object Storage Service Configuration
650
-
651
- This article uses MinIO as an example to explain the configuration process. If you are using another S3 service provider, please refer to their documentation for configuration.
652
-
653
- <Callout type="warning">
654
- Please remember to configure the corresponding S3 service provider's CORS settings to ensure that LobeHub can access the S3 service correctly.
655
-
656
- In this document, you need to allow cross-origin requests from `https://lobe.example.com`. This can either be configured in MinIO WebUI under `Configuration - API - Cors Allow Origin`, or in the Docker Compose configuration under `minio - environment - MINIO_API_CORS_ALLOW_ORIGIN`.
657
-
658
- If you use the second method (which is also the default), you will no longer be able to configure it in the MinIO WebUI.
659
- </Callout>
660
-
661
- You first need to access the WebUI for configuration:
662
-
663
- - If you have set up the reverse proxy as mentioned before, open `https://minio-ui.example.com`
664
- - Otherwise, after port mapping, open `http://localhost:9001`
665
-
666
- 1. Enter the `MINIO_ROOT_USER` and `MINIO_ROOT_PASSWORD` you set in the login interface, then click login.
667
-
668
- 2. In the left panel under User / Access Keys, click `Create New Access Key`, no additional modifications needed, and fill the generated `Access Key` and `Secret Key` into your `.env` file under `S3_ACCESS_KEY_ID` and `S3_SECRET_ACCESS_KEY`.
669
-
670
- <Image alt="Create MinIO Access Key" src="/blog/assetsfa2c650be15522ac2fd71a3e434a1b2e.webp" />
671
-
672
- 3. Restart the LobeHub service:
673
-
674
- ```sh
675
- docker compose up -d
676
- ```
677
-
678
- At this point, you have successfully deployed the LobeHub database version, and you can access your LobeHub service at `https://lobe.example.com`.
679
-
680
- #### Configuring Internal Server Communication with `INTERNAL_APP_URL`
681
-
682
- <Callout type="info">
683
- If you are deploying LobeHub behind a CDN (like Cloudflare) or reverse proxy, you may want to configure internal server-to-server communication to bypass the CDN/proxy layer for better performance.
684
- </Callout>
685
-
686
- You can configure the `INTERNAL_APP_URL` environment variable:
687
-
688
- ```yaml
689
- environment:
690
- - 'APP_URL=https://lobe.example.com' # Public URL for browser access
691
- - 'INTERNAL_APP_URL=http://localhost:3210' # Internal URL for server-to-server calls
692
- ```
693
-
694
- **How it works:**
695
-
696
- - `APP_URL`: Used for browser/client access, OAuth callbacks, webhooks, etc. (goes through CDN/proxy)
697
- - `INTERNAL_APP_URL`: Used for internal server-to-server communication (bypasses CDN/proxy)
698
-
699
- If `INTERNAL_APP_URL` is not set, it defaults to `APP_URL`.
700
-
701
- **Configuration options:**
702
-
703
- - `http://localhost:3210` - If using Docker with host network mode
704
- - `http://lobe:3210` - If using Docker network with service name
705
- - `http://127.0.0.1:3210` - Alternative localhost address
706
-
707
- <Callout type="tip">
708
- For Docker Compose deployments with `network_mode: 'service:network-service'`, use `http://localhost:3210` as the `INTERNAL_APP_URL`.
709
- </Callout>
710
-
711
- #### Configuration Files
712
-
713
- For convenience, here is a summary of example configuration files required for the production deployment using the Casdoor authentication scheme:
714
-
715
- - `.env`
716
-
717
- ```sh
718
- # Proxy, if you need it
719
- # HTTP_PROXY=http://localhost:7890
720
- # HTTPS_PROXY=http://localhost:7890
721
-
722
- # Other environment variables, as needed. You can refer to the environment variables configuration for the client version.
723
- # OPENAI_API_KEY=sk-xxxx
724
- # OPENAI_PROXY_URL=https://api.openai.com/v1
725
- # OPENAI_MODEL_LIST=...
726
-
727
- # ===========================
728
- # ====== Preset config ======
729
- # ===========================
730
- # if no special requirements, no need to change
731
- LOBE_PORT=3210
732
- CASDOOR_PORT=8000
733
- MINIO_PORT=9000
734
-
735
- # Postgres related, which are the necessary environment variables for DB
736
- LOBE_DB_NAME=LobeHub
737
- POSTGRES_PASSWORD=uWNZugjBqixf8dxC
738
-
739
- # Casdoor secret
740
- AUTH_CASDOOR_ID=943e627d79d5dd8a22a1
741
- AUTH_CASDOOR_SECRET=6ec24ac304e92e160ef0d0656ecd86de8cb563f1
742
-
743
- # MinIO S3 configuration
744
- MINIO_ROOT_USER=Joe
745
- MINIO_ROOT_PASSWORD=Crj1570768
746
-
747
- # Configure the bucket information of MinIO
748
- MINIO_LOBE_BUCKET=lobe
749
- S3_ACCESS_KEY_ID=dB6Uq9CYZPdWSZouPyEd
750
- S3_SECRET_ACCESS_KEY=aPBW8CVULkh8bw1GatlT0GjLihcXHLNwRml4pieS
751
- ```
752
-
753
- - `docker-compose.yml`
754
-
755
- ```yaml
756
- name: lobe-chat-database
757
- services:
758
- network-service:
759
- image: alpine
760
- container_name: lobe-network
761
- ports:
762
- - '${MINIO_PORT}:${MINIO_PORT}' # MinIO API
763
- - '9001:9001' # MinIO Console
764
- - '${CASDOOR_PORT}:${CASDOOR_PORT}' # Casdoor
765
- - '${LOBE_PORT}:3210' # LobeHub
766
- command: tail -f /dev/null
767
- networks:
768
- - lobe-network
769
-
770
- postgresql:
771
- image: pgvector/pgvector:pg17
772
- container_name: lobe-postgres
773
- ports:
774
- - '5432:5432'
775
- volumes:
776
- - './data:/var/lib/postgresql/data'
777
- environment:
778
- - 'POSTGRES_DB=${LOBE_DB_NAME}'
779
- - 'POSTGRES_PASSWORD=${POSTGRES_PASSWORD}'
780
- healthcheck:
781
- test: ['CMD-SHELL', 'pg_isready -U postgres']
782
- interval: 5s
783
- timeout: 5s
784
- retries: 5
785
- restart: always
786
- networks:
787
- - lobe-network
788
-
789
- minio:
790
- image: minio/minio:RELEASE.2025-04-22T22-12-26Z
791
- container_name: lobe-minio
792
- network_mode: 'service:network-service'
793
- volumes:
794
- - './s3_data:/etc/minio/data'
795
- environment:
796
- - 'MINIO_ROOT_USER=${MINIO_ROOT_USER}'
797
- - 'MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD}'
798
- # - 'MINIO_API_CORS_ALLOW_ORIGIN=http://localhost:${LOBE_PORT}'
799
- - 'MINIO_API_CORS_ALLOW_ORIGIN=https://lobe.example.com'
800
- restart: always
801
- command: >
802
- server /etc/minio/data --address ":${MINIO_PORT}" --console-address ":9001"
803
-
804
- casdoor:
805
- image: casbin/casdoor
806
- container_name: lobe-casdoor
807
- entrypoint: /bin/sh -c './server --createDatabase=true'
808
- network_mode: 'service:network-service'
809
- depends_on:
810
- postgresql:
811
- condition: service_healthy
812
- environment:
813
- RUNNING_IN_DOCKER: 'true'
814
- driverName: 'postgres'
815
- dataSourceName: 'user=postgres password=${POSTGRES_PASSWORD} host=postgresql port=5432 sslmode=disable dbname=casdoor'
816
- # origin: 'http://localhost:${CASDOOR_PORT}'
817
- origin: 'https://auth.example.com'
818
- runmode: 'dev'
819
- volumes:
820
- - ./init_data.json:/init_data.json
821
-
822
- lobe:
823
- image: lobehub/lobe-chat-database
824
- container_name: lobe-chat-database
825
- network_mode: 'service:network-service'
826
- depends_on:
827
- postgresql:
828
- condition: service_healthy
829
- network-service:
830
- condition: service_started
831
- minio:
832
- condition: service_started
833
- casdoor:
834
- condition: service_started
835
-
836
- environment:
837
- # - 'APP_URL=http://localhost:3210'
838
- - 'APP_URL=https://lobe.example.com'
839
-
840
- - 'AUTH_SSO_PROVIDERS=casdoor'
841
- - 'KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ='
842
- - 'AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg'
843
- # - 'AUTH_URL=http://localhost:${LOBE_PORT}/api/auth'
844
- - 'AUTH_URL=https://lobe.example.com/api/auth'
845
-
846
- # - 'AUTH_CASDOOR_ISSUER=http://localhost:${CASDOOR_PORT}'
847
- - 'AUTH_CASDOOR_ISSUER=https://auth.example.com'
848
-
849
- - 'DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@postgresql:5432/${LOBE_DB_NAME}'
850
- # - 'S3_ENDPOINT=http://localhost:${MINIO_PORT}'
851
- - 'S3_ENDPOINT=https://minio.example.com'
852
-
853
- - 'S3_BUCKET=${MINIO_LOBE_BUCKET}'
854
- # - 'S3_PUBLIC_DOMAIN=http://localhost:${MINIO_PORT}'
855
- - 'S3_PUBLIC_DOMAIN=https://minio.example.com'
856
-
857
- - 'S3_ENABLE_PATH_STYLE=1'
858
- - 'LLM_VISION_IMAGE_USE_BASE64=1'
859
- env_file:
860
- - .env
861
- restart: always
862
-
863
- volumes:
864
- data:
865
- driver: local
866
- s3_data:
867
- driver: local
868
-
869
- networks:
870
- lobe-network:
871
- driver: bridge
872
- ```
873
-
874
- [docker-pulls-link]: https://hub.docker.com/r/lobehub/lobe-chat-database
875
- [docker-pulls-shield]: https://img.shields.io/docker/pulls/lobehub/lobe-chat-database?color=45cc11&labelColor=black&style=flat-square
876
- [docker-release-link]: https://hub.docker.com/r/lobehub/lobe-chat-database
877
- [docker-release-shield]: https://img.shields.io/docker/v/lobehub/lobe-chat-database?color=369eff&label=docker&labelColor=black&logo=docker&logoColor=white&style=flat-square&sort=semver
878
- [docker-size-link]: https://hub.docker.com/r/lobehub/lobe-chat-database
879
- [docker-size-shield]: https://img.shields.io/docker/image-size/lobehub/lobe-chat-database?color=369eff&labelColor=black&style=flat-square&sort=semver