Ollama + Open WebUI with NGINX Proxy Manager

PHOTO EMBED

Tue Dec 03 2024 07:27:03 GMT+0000 (Coordinated Universal Time)

Saved by @Shex #ollama #docker-compose #ai #webui

version: '3.8'
services:
  ollama:
    volumes:
      - ollama:/root/.ollama
    container_name: ollama
    pull_policy: always
    tty: true
    restart: unless-stopped
    image: ollama/ollama:${OLLAMA_DOCKER_TAG-latest}

  open-webui:
    image: ghcr.io/open-webui/open-webui:${WEBUI_DOCKER_TAG-main}
    container_name: open-webui
    volumes:
      - open-webui:/app/backend/data
    depends_on:
      - ollama
    environment:
      - 'OLLAMA_BASE_URL=http://ollama:11434'
      - 'WEBUI_SECRET_KEY='
    extra_hosts:
      - host.docker.internal:host-gateway
    restart: unless-stopped

  nginx-proxy-manager:
    image: 'jc21/nginx-proxy-manager:latest'
    container_name: nginx-proxy-manager
    restart: unless-stopped
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - open-webui

volumes:
  ollama: {}
  open-webui: {}
content_copyCOPY

. Added the Nginx Proxy Manager service as `nginx-proxy-manager`. 2. Kept the port mappings as specified in your Nginx Proxy Manager compose file, including port 81 for the UI interface. 3. Included the volumes for Nginx Proxy Manager as specified. 4. Added a `depends_on` directive to ensure that the `open-webui` service starts before Nginx Proxy Manager. 5. Removed the previously added custom Nginx service, as Nginx Proxy Manager will handle the proxying. To use this setup: 1. Save this updated content to your `docker-compose.yml` file. 2. Run the services using: ``` docker-compose up -d ``` 3. Access the Nginx Proxy Manager UI at `http://your-host-ip:81`. 4. In Nginx Proxy Manager, you'll need to set up a proxy host for your `open-webui` service. Use the service name `open-webui` as the hostname and `8080` as the port when configuring the proxy host. This configuration allows you to use Nginx Proxy Manager to handle incoming requests and proxy them to your `open-webui` service. The `open-webui` service is not directly exposed to the host, improving security.