diff --git a/pages/docs/configuration/cdn/azure.mdx b/pages/docs/configuration/cdn/azure.mdx index f3d1047c7..63c58b4b0 100644 --- a/pages/docs/configuration/cdn/azure.mdx +++ b/pages/docs/configuration/cdn/azure.mdx @@ -86,6 +86,32 @@ fileStrategy: "azure_blob" This setting tells LibreChat to use the Azure Blob Storage implementation provided in your code. +## 5. Optional: Setup lifecycle management for temporary files + +Files uploaded during temporary conversations can be automatically cleared from Azure using lifecycle rules. + +- Go to your storage account in Azure. +- Navigate to "Data Management" -> "Lifecycle management". +- Click "Add a rule." + - Details + - **Rule name**: LibreChat temporary file expiration + - **Rule scope**: Limit blobs with filters + - **Blob type**: Block blobs + - **Blob subtype**: Base blobs + +![Screenshot of adding a lifecycle rule in Azure, demonstrating the "details" settings](/images/cdn/azure_rule_details.png) + + - Base blobs + - **If**: base blobs were created more than (days ago): set to # of days you want temporary files to remain (default: 30) + - **Then**: Delete the blob + +![Screenshot of adding a lifecycle rule in Azure, demonstrating the "base blobs" settings](/images/cdn/azure_rule_base_blobs.png) + + - Filter set + - **Blob prefix**: "[YOUR_AZURE_CONTAINER_NAME]/tmp/" (by default, `AZURE_CONTAINER_NAME` is `files`) + +![Screenshot of adding a lifecycle rule in Azure, demonstrating the "filter set" settings](/images/cdn/azure_rule_filter_set.png) + --- ## Summary @@ -107,6 +133,10 @@ In your `.env` file, set either: 4. **Configure LibreChat:** Set `fileStrategy` to `"azure_blob"` in your `librechat.yaml` configuration file. +4. **Optional: Configure Temporary Blob Expiration:** +Add a lifecycle rule to Azure to expire any keys prefixed with `tmp/`. + + With these steps, your LibreChat application will automatically create the container (if it doesn't exist) and manage file uploads, downloads, and deletions using Azure Blob Storage as your CDN. Managed Identity provides a secure alternative by eliminating the need for long-term credentials. ## Local Development with Azurite diff --git a/pages/docs/configuration/cdn/firebase.mdx b/pages/docs/configuration/cdn/firebase.mdx index 9bee12906..948c3caa9 100644 --- a/pages/docs/configuration/cdn/firebase.mdx +++ b/pages/docs/configuration/cdn/firebase.mdx @@ -94,6 +94,9 @@ FIREBASE_APP_ID=1:your_app_id #appId match /images/{userId}/{fileName} { allow read, write: if true; } + match /tmp/images/{userId}/{fileName} { + allow read, write: if true; + } } } ``` @@ -116,13 +119,28 @@ Finally, to enable the app use Firebase, you must set the following in your `lib For more information about the `librechat.yaml` config file, see the guide here: [Custom Endpoints & Configuration](/docs/configuration/librechat_yaml). - +### Optional: Setup lifecycle rule for temporary files -### Step-by-Step Guide to Set Up CORS for Firebase Storage +Files uploaded during temporary conversations can be automatically cleared from Firebase using lifecycle rules. +(These rules are provided by the underlying Google Cloud Storage platform, not Firebase.) ---- +- Go to your project in [Google Cloud Storage](https://console.cloud.google.com/storage). +- Open the "Buckets" tab, select your bucket. +- Go to "Lifecycle" tab. +- Click "Add a rule." + - **Action**: Delete object + +![Screenshot of adding a lifecycle rule in Firebase, demonstrating the "action" setting](/images/cdn/firebase_rule_action.png) + + - Object conditions + - **Object name matches prefix**: `tmp/` + - **Set Conditions**: "Age" to # of days you want temporary files to remain (default: 30) + +![Screenshot of adding a lifecycle rule in Firebase, demonstrating the "object conditions" settings](/images/cdn/firebase_rule_object_conditions.png) + +## Step-by-Step Guide to Set Up CORS for Firebase Storage -#### **Step 1: Create the CORS Configuration File** +### Step 1: Create the CORS Configuration File - Open a text editor of your choice. - Create a new file and name it `cors.json`. @@ -139,9 +157,7 @@ For more information about the `librechat.yaml` config file, see the guide here: ``` - Save the file. ---- - -#### **Step 2: Apply the CORS Configuration** +### Step 2: Apply the CORS Configuration - Open your terminal or command prompt. - Navigate to the directory where you saved the `cors.json` file. @@ -151,9 +167,7 @@ For more information about the `librechat.yaml` config file, see the guide here: gsutil cors set cors.json gs:// ``` ---- - -#### **Step 3: Verify the CORS Settings** +### Step 3: Verify the CORS Settings - To confirm that the CORS settings have been applied correctly, you can retrieve the current CORS configuration with the following command: @@ -163,9 +177,7 @@ gsutil cors get gs:// - The output should reflect the settings you specified in the `cors.json` file. ---- - -#### **Step 4: Test the Configuration** +### Step 4: Test the Configuration - Try exporting a convo as png from the allowed origin ("https://ai.example.com"). - If everything is set up correctly, you should not encounter any CORS issues. @@ -177,5 +189,3 @@ gsutil cors get gs:// --- That's it! You've successfully configured CORS for your Firebase Storage bucket to allow requests from a specific origin. Remember to replace `` with your actual bucket name and `https://ai.example.com` with your own domain when applying the configuration. - - diff --git a/pages/docs/configuration/cdn/s3.mdx b/pages/docs/configuration/cdn/s3.mdx index c12312fda..07f639108 100644 --- a/pages/docs/configuration/cdn/s3.mdx +++ b/pages/docs/configuration/cdn/s3.mdx @@ -114,6 +114,21 @@ fileStrategy: "s3" This setting tells LibreChat to use the S3 implementation provided in your code. +## 5. Optional: Setup S3 lifecycle rule for temporary files + +Files uploaded during temporary conversations can be automatically cleared from S3 using lifecycle rules. + +- Go to your bucket in S3. +- Open the "Management" tab. +- Click "Create lifecycle rule." + - **Lifecycle rule name**: LibreChat temporary file expiration + - **Rule scope**: "Limit the scope of this rule using one or more filters" + - **Prefix**: `tmp/` + - **Lifecycle rule actions**: check "Expire current versions of objects" + - **Days after object creation**: set to # of days you want temporary files to remain (default: 30) + +![Screenshot of adding the lifecycle rule in S3](/images/cdn/s3_lifecycle_rule.png) + ## Summary 1. **Create an AWS Account & IAM User (or configure IRSA):** @@ -130,6 +145,9 @@ This setting tells LibreChat to use the S3 implementation provided in your code. 4. **Configure LibreChat:** - Set `fileStrategy` to `"s3"` in your `librechat.yaml` configuration file. +5. **Optional: Configure Temporary File Expiration** +- Add a lifecycle rule to S3 to expire any keys prefixed with `tmp/`. + With these steps, your LibreChat application will use Amazon S3 to handle file uploads, downloads, and deletions, leveraging S3 as your CDN for static assets. Additionally, with IRSA support, your application can run securely on Kubernetes without embedding long-term AWS credentials. diff --git a/public/images/cdn/azure_rule_base_blobs.png b/public/images/cdn/azure_rule_base_blobs.png new file mode 100644 index 000000000..2d747b6c6 Binary files /dev/null and b/public/images/cdn/azure_rule_base_blobs.png differ diff --git a/public/images/cdn/azure_rule_details.png b/public/images/cdn/azure_rule_details.png new file mode 100644 index 000000000..d70ac76bd Binary files /dev/null and b/public/images/cdn/azure_rule_details.png differ diff --git a/public/images/cdn/azure_rule_filter_set.png b/public/images/cdn/azure_rule_filter_set.png new file mode 100644 index 000000000..c3d77c208 Binary files /dev/null and b/public/images/cdn/azure_rule_filter_set.png differ diff --git a/public/images/cdn/firebase_rule_action.png b/public/images/cdn/firebase_rule_action.png new file mode 100644 index 000000000..3f6d07492 Binary files /dev/null and b/public/images/cdn/firebase_rule_action.png differ diff --git a/public/images/cdn/firebase_rule_object_conditions.png b/public/images/cdn/firebase_rule_object_conditions.png new file mode 100644 index 000000000..3760562e4 Binary files /dev/null and b/public/images/cdn/firebase_rule_object_conditions.png differ diff --git a/public/images/cdn/s3_lifecycle_rule.png b/public/images/cdn/s3_lifecycle_rule.png new file mode 100644 index 000000000..2d3043126 Binary files /dev/null and b/public/images/cdn/s3_lifecycle_rule.png differ