Skip to content

Commit

Permalink
Merge pull request #346 from silentoplayz/update-redis-tut
Browse files Browse the repository at this point in the history
Update redis.md
  • Loading branch information
tjbck authored Jan 8, 2025
2 parents 4864fd7 + d44d65d commit 7fddea9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
6 changes: 6 additions & 0 deletions docs/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ Take a deeper dive into configurations and development tips in our [Advanced Top

---

## 🔄 Updating Open WebUI

Stay current with the latest features and security patches with our [Updating Open WebUI](./updating) guide.

---

Happy exploring! 🎉 If you have questions, join our [community](https://discord.gg/5rJgQTnV4s) or raise an issue on [GitHub](https://github.com/open-webui/open-webui).
45 changes: 40 additions & 5 deletions docs/tutorials/integrations/redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ This documentation page outlines the steps required to integrate Redis with Open
* A valid Open WebUI instance (running version 1.0 or higher)
* A Redis container (we will use `docker.io/valkey/valkey:8.0.1-alpine` in this example, which is based on the latest Redis 7.x release)
* Docker Composer (version 2.0 or higher) installed on your system
* A Docker network for communication between Open WebUI and Redis
* Basic understanding of Docker, Redis, and Open WebUI

## Setting up Redis

Expand Down Expand Up @@ -50,12 +52,30 @@ services:
options:
max-size: "1m"
max-file: "1"
networks:
- openwebui-network

volumes:
redis-data:

networks:
openwebui-network:
external: true
```
This configuration sets up a Redis container named `redis-valkey` and mounts a volume for data persistence. The `healthcheck` directive ensures that the container is restarted if it fails to respond to the `ping` command.
:::info Notes
The `ports` directive is not included in this configuration, as it is not necessary in most cases. The Redis service will still be accessible from within the Docker network by the Open WebUI service. However, if you need to access the Redis instance from outside the Docker network (e.g., for debugging or monitoring purposes), you can add the `ports` directive to expose the Redis port (e.g., `6379:6379`).

The above configuration sets up a Redis container named `redis-valkey` and mounts a volume for data persistence. The `healthcheck` directive ensures that the container is restarted if it fails to respond to the `ping` command. The `--save 30 1` command option saves the Redis database to disk every 30 minutes if at least 1 key has changed.

:::

To create a Docker network for communication between Open WebUI and Redis, run the following command:

```bash
docker network create openwebui-network
```

## Configuring Open WebUI

Expand All @@ -67,15 +87,30 @@ WEBSOCKET_MANAGER="redis"
WEBSOCKET_REDIS_URL="redis://redis:6379/1"
```

These environment variables enable websocket support, specify Redis as the websocket manager, and define the Redis URL. Make sure to replace the `WEBSOCKET_REDIS_URL` value with the actual URL of your Redis instance.
These environment variables enable websocket support, specify Redis as the websocket manager, and define the Redis URL. Make sure to replace the `WEBSOCKET_REDIS_URL` value with the actual IP address of your Redis instance.

When running Open WebUI using Docker, you need to connect it to the same Docker network:

```bash
docker run -d \
--name open-webui \
--network openwebui-network \
-v open-webui:/app/backend/data \
-e ENABLE_WEBSOCKET_SUPPORT="true" \
-e WEBSOCKET_MANAGER="redis" \
-e WEBSOCKET_REDIS_URL="redis://127.0.0.1:6379/1" \
ghcr.io/open-webui/open-webui:main
```

Replace `127.0.0.1` with the actual IP address of your Redis container in the Docker network.

## Verification

If you have properly set up Redis and configured Open WebUI, you should see the following log message when starting your Open WebUI instance:

`DEBUG:open_webui.socket.main:Using Redis to manage websockets.`

This confirms that Open WebUI is using Redis for websocket management. You can also use the `docker exec` command using Command Prompt to verify that the Redis instance is running and accepting connections:
This confirms that Open WebUI is using Redis for websocket management. You can also use the `docker exec` command to verify that the Redis instance is running and accepting connections:

```bash
docker exec -it redis-valkey redis-cli -p 6379 ping
Expand All @@ -92,7 +127,7 @@ docker exec -it redis-valkey valkey-cli -p 6379 ping
If you encounter issues with Redis or websocket support in Open WebUI, you can refer to the following resources for troubleshooting:

* [Redis Documentation](https://redis.io/docs)
* [Open WebUI Documentation](https://open-webui.github.io/docs)
* [Docker Composer Documentation](https://docs.docker.com/compose/overview/)
* [Docker Compose Documentation](https://docs.docker.com/compose/overview/)
* [sysctl Documentation](https://man7.org/linux/man-pages/man8/sysctl.8.html)

By following these steps and troubleshooting tips, you should be able to set up Redis with Open WebUI for websocket support and enable real-time communication and updates between clients and your application.

0 comments on commit 7fddea9

Please sign in to comment.