Skip to content

Commit

Permalink
📖 docs: MEILI_NO_SYNC, TRUST_PROXY, and Support for Redis Clusters (
Browse files Browse the repository at this point in the history
#243)

* docs: Add instructions for disabling MeiliSearch index sync in multi-node setups

* 📖 add section on Trust Proxy configuration in dotenv.mdx

* Updated REDIS section in dotenv.mdx

* chore: fix char issue

---------

Co-authored-by: Pedro Reis <[email protected]>
Co-authored-by: Gil Assunção <[email protected]>
  • Loading branch information
3 people authored Feb 20, 2025
1 parent 15a0eee commit bce321d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
39 changes: 37 additions & 2 deletions pages/docs/configuration/dotenv.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ For more info see:
]}
/>

### Trust proxy
Use the address that is at most n number of hops away from the Express application.
req.socket.remoteAddress is the first hop, and the rest are looked for in the X-Forwarded-For header from right to left.
A value of 0 means that the first untrusted address would be req.socket.remoteAddress, i.e. there is no reverse proxy.
The `TRUST_PROXY` environment variable default is set to `1`.

Refer to [Express.js - trust proxy](https://expressjs.com/en/guide/behind-proxies.html) for more information about this.

<OptionTable
options={[
['TRUST_PROXY', 'number', 'Specifies the number of hops.', 'HOST=1'],
]}
/>

### Static File Handling

<OptionTable
Expand Down Expand Up @@ -604,6 +618,14 @@ This master key must be at least 16 bytes, composed of valid UTF-8 characters. M
]}
/>

To prevent LibreChat from attempting a database indexing sync with Meilisearch, you can set the following environment variable to `true`. This is useful in a node cluster, or multi-node setup, where only one instance should be responsible for indexing.

<OptionTable
options={[
['MEILI_NO_SYNC', 'string', 'Toggle for disabling Mellisearch index sync','MEILI_NO_SYNC=true'],
]}
/>

## User System
This section contains the configuration for:

Expand Down Expand Up @@ -1002,9 +1024,22 @@ LibreChat supports Google Tag Manager for analytics. You will need a Google Tag

**Important:** If using Redis, you should flush the cache after changing any LibreChat settings.

If you are using Redis, you will need to set the following variables:

* `REDIS_URI`: The URI for your Redis instance.
* `USE_REDIS`: Set to `true` to enable Redis.
* `USE_REDIS_CLUSTER`: Set to `true` to enable Redis Cluster mode.
* `REDIS_CA`: The path to the PEM-encoded certificate authority file for Redis TLS connections.
* `REDIS_KEY_PREFIX`: A prefix to be added to all keys in the Redis database. Defaults to empty string if not specified.
* `REDIS_MAX_LISTENERS`: The maximum number of event listeners allowed for the Redis client instance. It helps prevent memory leaks by limiting event listeners. If set to 0 (zero), it will be considered limitless. Defaults to 10 if not specified.

<OptionTable
options={[
['REDIS_URI', 'string', 'Redis URI.','# REDIS_URI='],
['USE_REDIS', 'boolean', 'Use Redis.','# USE_REDIS='],
['REDIS_URI', 'string', 'Redis URI.', '# REDIS_URI="10.11.12.13:6379"'],
['USE_REDIS', 'boolean', 'Use Redis.', '# USE_REDIS="true"'],
['USE_REDIS_CLUSTER', 'boolean', 'User Redis Cluster mode', '# USE_REDIS_CLUSTER="true"'],
['REDIS_CA', 'string', 'Path to certificate', '# REDIS_CA="/path/to/file.crt"'],
['REDIS_KEY_PREFIX', 'string', 'Prefix for Redis keys', '# REDIS_KEY_PREFIX="librechat-staging:"'],
['REDIS_MAX_LISTENERS', 'number', 'Maximum number of event listeners allowed for the Redis client instance', '# REDIS_MAX_LISTENERS=20'],
]}
/>
10 changes: 9 additions & 1 deletion pages/docs/configuration/meilisearch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ Follow these steps to set up MeiliSearch for LibreChat:

That's it! With MeiliSearch set up and configured, LibreChat should now have the Conversation search feature enabled, allowing users to perform full-text searches, benefit from typo tolerance, and experience instant search results for their past conversations.

Note: Make sure to keep the MeiliSearch process running in the background for the search functionality to work correctly. You may want to set up a script or service to keep MeiliSearch running persistently.
Note: Make sure to keep the MeiliSearch process running in the background for the search functionality to work correctly. You may want to set up a script or service to keep MeiliSearch running persistently.

## 8. Optional: Disable Meilisearch/Database Sync in a Multi-node Setup

If you're running LibreChat in a node cluster, or multi-node setup, and want to disable the MeiliSearch indexing sync, you can set the `MEILI_NO_SYNC` environment variable to `true` in your `.env` file. This will prevent your database documents from syncing redundantly across multiple LibreChat instances, which can also lead to unnecessary resource consumption, as only one instance should be responsible for indexing.

```sh filename=".env"
MEILI_NO_SYNC=true
```

0 comments on commit bce321d

Please sign in to comment.