Skip to content

LibreChat

LibreChat is a free, open-source, and self-hosted AI chat platform that provides a unified, privacy-focused interface to interact with multiple artificial intelligence providers and large language models (LLMs).

Install LibreChat

  1. Follow the LibreChat installation guide.
  2. Install LibreChat using either the Docker or npm method.
  3. Start the LibreChat service.
  4. Access LibreChat on port 3080.
  1. Follow the LibreChat installation guide to set up the self-hosted LibreChat requirements, including the .env file.
  2. Create ls-net network with following command:

docker network inspect ls-net >/dev/null 2>&1 || docker network create ls-net
3. Add the following ls-net external network to the LibreChat project’s docker-compose.yml file:

```yaml
services:
  api:
    container_name: LibreChat
    ports:
      - "${PORT}:${PORT}"
    depends_on:
      - mongodb
      - rag_api
    image: registry.librechat.ai/danny-avila/librechat-dev:latest
    restart: always
    user: "${UID}:${GID}"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    environment:
      - HOST=0.0.0.0
      - MONGO_URI=mongodb://mongodb:27017/LibreChat
      - MEILI_HOST=http://meilisearch:7700
      - LIBRECHAT_TEMP_CREDENTIALS_PATH=/app/data/.env.temp
      - RAG_PORT=${RAG_PORT:-8000}
      - RAG_API_URL=http://rag_api:${RAG_PORT:-8000}
      - PROXY=${PROXY:-}
      - HTTP_PROXY=${HTTP_PROXY:-}
      - HTTPS_PROXY=${HTTPS_PROXY:-}
      - NO_PROXY=${NO_PROXY:-localhost,127.0.0.1,::1},${no_proxy:-},mongodb,chat-mongodb,meilisearch,chat-meilisearch,rag_api, vectordb,host.docker.internal
      - http_proxy=${http_proxy:-}
      - https_proxy=${https_proxy:-}
      - no_proxy=${no_proxy:-localhost,127.0.0.1,::1},${NO_PROXY:-},mongodb,chat-mongodb,meilisearch,chat-meilisearch,rag_api,vectordb,host.docker.internal
    volumes:
      - type: bind
        source: ./.env
        target: /app/.env
      - ./images:/app/client/public/images
      - ./uploads:/app/uploads
      - ./logs:/app/logs
      - ./skill:/app/skill
      - librechat-data:/app/data
... SKIP ...
networks:
  default:
    name: ls-net
    external: true
```

Set up OpenLiteSpeed proxy with AutoSSL

The easiest way to install OpenLiteSpeed, configure it as a reverse proxy, and enable AutoSSL is to use the ols1clk script.

Before continuing, ensure that your domain points to the server.

Replace www.example.com with your domain name, and run the following command:

bash <(curl -fsSL https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh) --proxy-c --proxy-port 3080  --autocert --sitedomain www.example.com

This command automatically:

  1. Download the ols-proxy-docker-env repository:

    git clone https://github.com/litespeedtech/ols-proxy-docker-env
    cd ols-proxy-docker-env
    
  2. Copy the example environment file:

    cp .env.example .env
    
  3. Edit .env with your configuration values:

    OLS_IMAGE=litespeedtech/openlitespeed:latest
    BACKEND_IP=LibreChat
    BACKEND_PORT=3080
    DOMAIN=www.example.com
    PROXY_METHOD=context
    PROXY_SOCKET=false
    ACME_EMAIL=admin@example.com
    
  4. Start the proxy:

    docker compose up -d
    

Verify the proxy configuration

Open https://www.example.com in a browser. The application interface should load through OpenLiteSpeed over HTTPS.

Warning

After verifying the configuration, restrict public access to port 3080 using your firewall. Alternatively, you can configure the service to listen on 127.0.0.1 only, so port 3080 is not publicly accessible.

Optional settings

You can further enhance your site's security by enabling additional security features in the .env file, such as:

These other security features can be configured through the WebAdmin Console:

See the OpenLiteSpeed Security Guide for more information.

Warning

Some security features may interfere with application services or block legitimate requests. Test these settings thoroughly before applying them in a production environment.