Skip to content

Commit

Permalink
⚡ docs: Add static file configuration & update how to contribute (#98)
Browse files Browse the repository at this point in the history
* add static file & update doc documentation

* add DISABLE_COMPRESSION

* 📝 docs: rag_api.mdx for running RAG API with Ollama nomic-embed-text (#92)

* feat: Update Traefik docs about support for static file caching and compression

* Update traefik.mdx

* docs: Mention static file caching and compression for NGINX

---------

Co-authored-by: mawburn <[email protected]>
Co-authored-by: matt burnett <[email protected]>
Co-authored-by: Linh <[email protected]>
  • Loading branch information
4 people authored Aug 5, 2024
1 parent 3cb41e3 commit 6d58312
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 30 deletions.
78 changes: 52 additions & 26 deletions pages/docs/configuration/dotenv.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ While the default settings provide a solid foundation for a standard `docker` in
Alternatively, you can create a new file named `docker-compose.override.yml` in the same directory as your main `docker-compose.yml` file for LibreChat, where you can set your .env variables as needed under `environment`, or modify the default configuration provided by the main `docker-compose.yml`, without the need to directly edit or duplicate the whole file.

For more info see:
For more info see:

- Our quick guide:
- Our quick guide:
- **[Docker Override](/docs/configuration/docker_override)**

- The official docker documentation:
- The official docker documentation:
- **[docker docs - understanding-multiple-compose-files](https://docs.docker.com/compose/multiple-compose-files/extends/#understanding-multiple-compose-files)**
- **[docker docs - merge-compose-files](https://docs.docker.com/compose/multiple-compose-files/merge/#merge-compose-files)**
- **[docker docs - specifying-multiple-compose-files](https://docs.docker.com/compose/reference/#specifying-multiple-compose-files)**

- You can also view an example of an override file for LibreChat in your LibreChat folder and on GitHub:
- You can also view an example of an override file for LibreChat in your LibreChat folder and on GitHub:
- **[docker-compose.override.example](https://github.com/danny-avila/LibreChat/blob/main/docker-compose.override.yml.example)**

---
Expand All @@ -42,6 +42,28 @@ For more info see:
]}
/>

#### Static File Handling

<OptionTable
options={[
['STATIC_CACHE_MAX_AGE', 'string', 'Cache-Control max-age in seconds','STATIC_CACHE_MAX_AGE=604800'],
['STATIC_CACHE_S_MAX_AGE', 'string', 'Custom footer.','STATIC_CACHE_S_MAX_AGE="259200"'],
['DISABLE_COMPRESSION', 'boolean', 'Disables compression for static files.','DISABLE_COMPRESSION=false'],
]}
/>

**Behaviour:**

Sets the [Cache-Control](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) headers for static files. These configurations only trigger when the `NODE_ENV` is set to `production`.

* Uncomment `STATIC_CACHE_MAX_AGE` to change the local `max-age` for static files. By default this is set to 4 weeks.
* Uncomment `STATIC_CACHE_S_MAX_AGE` empty to remove the footer. This is for the "shared cache," which is used by CDNs and proxies. By default this is set to 1 week.
* Set `DISABLE_COMPRESSION` to `true` to disable compression for static files. This is useful if you have another service in front of your service handling compression for you. By default this is set to `false`.

<Callout type="warning" title="Warning">
- This only affects static files served by the API server and is not applicable to _Firebase_, _NGINX_, or any other configurations.
</Callout>


### MongoDB Database

Expand All @@ -52,7 +74,7 @@ For more info see:
/>
Change this to your MongoDB URI if different. You should add `LibreChat` or your own `APP_TITLE` as the database name in the URI.

If you are using an online database, the URI format is `mongodb+srv://<username>:<password>@<host>/<database>?<options>`. Your `MONGO_URI` should look like this:
If you are using an online database, the URI format is `mongodb+srv://<username>:<password>@<host>/<database>?<options>`. Your `MONGO_URI` should look like this:
* `mongodb+srv://username:[email protected]/LibreChat?retryWrites=true` (`retryWrites` is the only option you need when using the online database.)

Alternatively you can use `documentDb` that emulates `mongoDb` but it:
Expand All @@ -61,7 +83,7 @@ Alternatively you can use `documentDb` that emulates `mongoDb` but it:
* requires TLS connection, hence use parameters `tls=true` to enable TLS and `tlsCAFile=/path-to-ca/bundle.pem` to point to the AWS provided CA bundle file

The URI for `documentDb` will look like:
* `mongodb+srv://username:password@domain/dbname?retryWrites=false&tls=true&tlsCAFile=/path-to-ca/bundle.pem`
* `mongodb+srv://username:password@domain/dbname?retryWrites=false&tls=true&tlsCAFile=/path-to-ca/bundle.pem`

See also:

Expand All @@ -81,7 +103,7 @@ To configure LibreChat for local use or custom domain deployment, set the follow
]}
/>

When deploying LibreChat to a custom domain, replace `http://localhost:3080` with your deployed URL
When deploying LibreChat to a custom domain, replace `http://localhost:3080` with your deployed URL
- e.g. `https://librechat.example.com`.

### Prevent Public Search Engines Indexing
Expand Down Expand Up @@ -116,10 +138,10 @@ LibreChat has built-in central logging, see [Logging System](/docs/configuration
]}
/>

Note:
Note:
* `DEBUG_LOGGING` can be used with either `DEBUG_CONSOLE` or `CONSOLE_JSON` but not both.
* `DEBUG_CONSOLE` and `CONSOLE_JSON` are mutually exclusive.
* `CONSOLE_JSON`: When handling console logs in cloud deployments (such as GCP or AWS), enabling this will dump the logs with a UTC timestamp and format them as JSON.
* `CONSOLE_JSON`: When handling console logs in cloud deployments (such as GCP or AWS), enabling this will dump the logs with a UTC timestamp and format them as JSON.
* See: [feat: Add CONSOLE_JSON](https://github.com/danny-avila/LibreChat/pull/2146)

Note: `DEBUG_CONSOLE` is not recommended, as the outputs can be quite verbose, and so it's disabled by default.
Expand All @@ -135,7 +157,7 @@ Note: `DEBUG_CONSOLE` is not recommended, as the outputs can be quite verbose, a
/>

### Configuration Path - `librechat.yaml`
Specify an alternative location for the LibreChat configuration file.
Specify an alternative location for the LibreChat configuration file.
You may specify an **absolute path**, a **relative path**, or a **URL**. The filename in the path is flexible and does not have to be `librechat.yaml`; any valid configuration file will work.

> **Note**: If you prefer LibreChat to search for the configuration file in the root directory (which is the default behavior), simply leave this option commented out.
Expand Down Expand Up @@ -308,15 +330,15 @@ To securely store credentials, you need a fixed key and IV. You can set them her
/>

<Callout type="warning" title="Warning">
**Warning:** If you don't set `CREDS_KEY` and `CREDS_IV`, the app will crash on startup.
**Warning:** If you don't set `CREDS_KEY` and `CREDS_IV`, the app will crash on startup.
- You can use this [Key Generator](/toolkit/creds_generator) to generate them quickly.
</Callout>

#### Azure AI Search
This plugin supports searching Azure AI Search for answers to your questions. See: [Azure AI Search](/docs/configuration/tools/azure_ai_search)

<OptionTable
options={[
options={[
['AZURE_AI_SEARCH_SERVICE_ENDPOINT', 'string', 'The service endpoint for Azure AI Search.','AZURE_AI_SEARCH_SERVICE_ENDPOINT='],
['AZURE_AI_SEARCH_INDEX_NAME', 'string', 'The index name for Azure AI Search.','AZURE_AI_SEARCH_INDEX_NAME='],
['AZURE_AI_SEARCH_API_KEY', 'string', 'The API key for Azure AI Search.','AZURE_AI_SEARCH_API_KEY='],
Expand Down Expand Up @@ -612,7 +634,7 @@ see: **[Automated Moderation](/docs/configuration/mod_system)**
#### Message rate limiting (per user & IP)

<OptionTable
options={[
options={[
['LIMIT_CONCURRENT_MESSAGES', 'boolean', 'Whether to limit the amount of messages a user can send per request.','LIMIT_CONCURRENT_MESSAGES=true'],
['CONCURRENT_MESSAGE_MAX', 'integer', 'The max amount of messages a user can send per request.','CONCURRENT_MESSAGE_MAX=2'],
]}
Expand All @@ -625,7 +647,7 @@ see: **[Automated Moderation](/docs/configuration/mod_system)**
##### IP Limiter:

<OptionTable
options={[
options={[
['LIMIT_MESSAGE_IP', 'boolean', 'Whether to limit the amount of messages an IP can send per `MESSAGE_IP_WINDOW`.','LIMIT_MESSAGE_IP=true'],
['MESSAGE_IP_MAX', 'integer', 'The max amount of messages an IP can send per `MESSAGE_IP_WINDOW`.','MESSAGE_IP_MAX=40'],
['MESSAGE_IP_WINDOW', 'integer', 'In minutes, determines the window of time for `MESSAGE_IP_MAX` messages.','MESSAGE_IP_WINDOW=1'],
Expand All @@ -635,7 +657,7 @@ see: **[Automated Moderation](/docs/configuration/mod_system)**
##### User Limiter:

<OptionTable
options={[
options={[
['LIMIT_MESSAGE_USER', 'boolean', 'Whether to limit the amount of messages an user can send per `MESSAGE_USER_WINDOW`.','LIMIT_MESSAGE_USER=false'],
['MESSAGE_USER_MAX', 'integer', 'The max amount of messages an user can send per `MESSAGE_USER_WINDOW`.','MESSAGE_USER_MAX=40'],
['MESSAGE_USER_WINDOW', 'integer', 'In minutes, determines the window of time for `MESSAGE_USER_MAX` messages.','MESSAGE_USER_WINDOW=1'],
Expand Down Expand Up @@ -676,7 +698,7 @@ see: **[Authentication System](/docs/configuration/authentication)**
</div>
</div>

- General Settings:
- General Settings:

<OptionTable
options={[
Expand All @@ -693,7 +715,7 @@ see: **[Authentication System](/docs/configuration/authentication)**
> **Quick Tip:** Even with registration disabled, add users directly to the database using `npm run create-user`.
> **Quick Tip:** With registration disabled, you can delete a user with `npm run delete-user [email protected]`.
- Session and Refresh Token Settings:
- Session and Refresh Token Settings:

<OptionTable
options={[
Expand All @@ -704,9 +726,9 @@ see: **[Authentication System](/docs/configuration/authentication)**

- For more information: **[Refresh Token](https://github.com/danny-avila/LibreChat/pull/927)**

- JWT Settings:
- JWT Settings:

You should use new secure values. The examples given are 32-byte keys (64 characters in hex).
You should use new secure values. The examples given are 32-byte keys (64 characters in hex).
Use this replit to generate some quickly: **[JWT Keys](/toolkit/creds_generator)**

<OptionTable
Expand Down Expand Up @@ -769,7 +791,7 @@ For more information: **[Google Authentication](/docs/configuration/authenticati

#### [OpenID Connect](/docs/configuration/authentication/OAuth2-OIDC#openid-connect)

For more information:
For more information:
- [AWS Cognito](/docs/configuration/authentication/OAuth2-OIDC/aws)
- [Azure Entra/AD](/docs/configuration/authentication/OAuth2-OIDC/azure)
- [Keycloak](/docs/configuration/authentication/OAuth2-OIDC/keycloak)
Expand Down Expand Up @@ -828,7 +850,7 @@ Email is used for account verification and password reset. See: **[Email setup](
**Important Note**: All of the service or host, username, and password, and the From address must be set for email to work.

> **Warning**: If using `EMAIL_SERVICE`, **do NOT** set the extended connection parameters:
> HOST, PORT, ENCRYPTION, ENCRYPTION_HOSTNAME, ALLOW_SELFSIGNED.
> HOST, PORT, ENCRYPTION, ENCRYPTION_HOSTNAME, ALLOW_SELFSIGNED.
> Failing to set valid values here will result in LibreChat using the unsecured password reset!
See: **[nodemailer well-known-services](https://community.nodemailer.com/2-0-0-beta/setup-smtp/well-known-services/)**
Expand Down Expand Up @@ -857,7 +879,7 @@ See: **[Firebase CDN Configuration](/docs/configuration/firebase)**
</Callout>

<OptionTable
options={[
options={[
['FIREBASE_API_KEY', 'string', 'The API key for your Firebase project.', 'FIREBASE_API_KEY='],
['FIREBASE_AUTH_DOMAIN', 'string', 'The Firebase Auth domain for your project.', 'FIREBASE_AUTH_DOMAIN='],
['FIREBASE_PROJECT_ID', 'string', 'The ID of your Firebase project.', 'FIREBASE_PROJECT_ID='],
Expand All @@ -879,9 +901,13 @@ See: **[Firebase CDN Configuration](/docs/configuration/firebase)**

**Behaviour:**

* If `HELP_AND_FAQ_URL` is empty or commented, the button is enabled.
* If `HELP_AND_FAQ_URL` is set to a URL (e.g., `https://example.com`), the button is enabled and links to that URL.
* If `HELP_AND_FAQ_URL` is set to `/`, the button is disabled.
Sets the [Cache-Control](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) headers for static files. These configurations only trigger when the `NODE_ENV` is set to `production`.

Properly setting cache headers is crucial for optimizing the performance and efficiency of your web application. By controlling how long browsers and CDNs store copies of your static files, you can significantly reduce server load, decrease page load times, and improve the overall user experience.

* Uncomment `STATIC_CACHE_MAX_AGE` to change the `max-age` for static files. By default this is set to 4 weeks.
* Uncomment `STATIC_CACHE_S_MAX_AGE` to change the `s-maxage` for static files. By default this is set to 1 week.
- This is for the _shared cache_, which is used by CDNs and proxies.

#### App Title and Footer

Expand Down Expand Up @@ -942,4 +968,4 @@ LibreChat supports Google Tag Manager for analytics. You will need a Google Tag
['REDIS_URI', 'string', 'Redis URI.','# REDIS_URI='],
['USE_REDIS', 'boolean', 'Use Redis.','# USE_REDIS='],
]}
/>
/>
18 changes: 15 additions & 3 deletions pages/docs/documentation/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ Consider publishing a blog post when a document is an extension of an existing o

</Callout>

## Getting Started

- Fork the LibreChat Documentation repository: [https://github.com/LibreChat-AI/librechat.ai](https://github.com/LibreChat-AI/librechat.ai)

- Create a branch on your fork, name it properly, and link it to the original repository.

```sh filename="Download your LibreChat.ai branch"
git clone -b branch-name https://github.com/username/librechat.ai.git
```

> Replace `branch-name` and `username` with your details
## Creating New Documents

To create a new document:
Expand Down Expand Up @@ -73,7 +85,7 @@ Whenever possible, upload assets (e.g., images) to GitHub instead of storing the

### Images

**Note In the followng example:**
**Note In the followng example:**
- I provided screenshots for both lihgt and dark mode.
- I used `Image from 'next/image'` wich gave me 4x improvement on the image file size for better performances.

Expand All @@ -96,9 +108,9 @@ import Image from 'next/image'
### How to Upload Images and Videos on GitHub

<Callout title="Method A" emoji="🅰️" collapsible>
- Go to the LibreChat repository
- Go to the LibreChat repository
- Find a random conversation or PR
- Paste an image from your clipboard into the text input box. It will automatically be converted into a URL.
- Paste an image from your clipboard into the text input box. It will automatically be converted into a URL.
- Copy and paste the resulting URL in your document. (Then exit the page without actually posting the comment.😉)

![image](https://github.com/danny-avila/LibreChat/assets/32828263/c1612f93-a6c0-4af7-9965-9f83872cff00)
Expand Down
15 changes: 14 additions & 1 deletion pages/docs/remote/nginx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,17 @@ Nginx can be configured to act as a web application firewall (WAF) by leveraging
4. Reload Nginx:
- `sudo systemctl reload nginx`

By enabling OWASP CRS in your Nginx configuration, you can leverage the comprehensive set of rules provided by the project to detect and mitigate various web application vulnerabilities and attacks, such as SQL injection, cross-site scripting (XSS), remote file inclusion, and more.
By enabling OWASP CRS in your Nginx configuration, you can leverage the comprehensive set of rules provided by the project to detect and mitigate various web application vulnerabilities and attacks, such as SQL injection, cross-site scripting (XSS), remote file inclusion, and more.

## Static File Caching and Compression

LibreChat now supports static file caching and compression natively. If you're using NGINX to handle compression, you should disable compression in LibreChat to avoid redundant processing. You can do this by setting the `DISABLE_COMPRESSION` environment variable to `true` in your LibreChat configuration.

```.env
# .env file
DISABLE_COMPRESSION=true
```

This will prevent LibreChat from compressing static files, allowing NGINX to handle compression more efficiently.

For more information on static file handling in LibreChat, including caching options, refer to the [Static File Handling](/docs/configuration/dotenv#static-file-handling) documentation.
13 changes: 13 additions & 0 deletions pages/docs/remote/traefik.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,16 @@ You can now access your LibreChat instance at `https://your.domain.name`. Traefi
- The Traefik configuration listens on ports 80 and 443 for HTTP and HTTPS traffic, respectively. Ensure that these ports are open on your server's firewall.
- Traefik stores SSL/TLS certificates in the `./letsencrypt` directory on your host machine. You may want to back up this directory periodically.
- For more advanced configuration options, refer to the official Traefik documentation: [https://doc.traefik.io/](https://doc.traefik.io/)

## Static File Caching and Compression

LibreChat now supports static file caching and compression natively. If you're using Traefik to handle compression, you should disable compression in LibreChat to avoid redundant processing. You can do this by setting the `DISABLE_COMPRESSION` environment variable to `true` in your LibreChat configuration.

```.env
# .env file
DISABLE_COMPRESSION=true
```

This will prevent LibreChat from compressing static files, allowing Traefik to handle compression more efficiently.

For more information on static file handling in LibreChat, including caching options, refer to the [Static File Handling](/docs/configuration/dotenv#static-file-handling) documentation.

0 comments on commit 6d58312

Please sign in to comment.