3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Open WebUIを動かす

3
Last updated at Posted at 2026-06-16

Open WebUIを動かす

目標

ローカルLLMがかなり実用的になってきたので、いつでもローカルLLMをチャットボットとして使えるようOpen WebUIを設定しておきたい。Web検索はあったほうがローカルLLMの知識不足を補えるため、Web検索を必須とする。

Web検索には、外部サービスを使うことも使うことができるが、SearXNGでローカル動作を目指す。

Open WebUIは作業用パソコンで動作させるが、ローカルLLMは複数GPUを搭載した他のコンピュータで高速に動作させる。

次のような構成にする。

Ollama server
  127.0.0.1:11434
      ↑ SSH tunnel
Docker host
  127.0.0.1:11434
      ↑
Open WebUI container
SearXNG container

注:もちろん、WebUIを導入するコンピュータが高性能なら、ollamaを別のPCに入れる必要はない。また、その場合も、この記事の手法が使える(SSHトンネリングを無視すれば良い)。

ollamaサーバへのトンネリング

事前にollamaが動いているサーバがあるとします。

SSHトンネリング

ssh -N -L 11434:127.0.0.1:11434 your_user@ollama-server

これで、localhost:11434でollamaが動く。

動作確認

curl http://127.0.0.1:11434/api/tags

このコマンドで、ollamaの動作が確認できればトンネリングが成功している。

その他

以上の操作で、GitHub Copilot、OpenCode、Claude Codeでollamaも使える。GitHub Copilotを除き、エージェントでollamaを使うには別途設定が必要である

作業ディレクトリ作成

mkdir local-llm-search
cd local-llm-search
mkdir searxng

yamlの作成

上のコマンドを入力した後、つまりlocal-llm-searchにdocker用のyaml、docker-compose.ymlを作成する。

nano docker-compose.yml
services:
  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    container_name: open-webui
    restart: unless-stopped
    ports:
      - "3000:8080"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    environment:
      # 外部OllamaへSSHトンネル経由で接続
      OLLAMA_BASE_URL: "http://host.docker.internal:11434"

      # Web検索を有効化
      ENABLE_WEB_SEARCH: "true"
      WEB_SEARCH_ENGINE: "searxng"
      SEARXNG_QUERY_URL: "http://searxng:8080/search?q=<query>&format=json"
      WEB_SEARCH_RESULT_COUNT: "5"
      WEB_SEARCH_CONCURRENT_REQUESTS: "5"

      # 必要なら認証
      WEBUI_AUTH: "true"

    volumes:
      - open-webui-data:/app/backend/data
    depends_on:
      - searxng

  searxng:
    image: docker.io/searxng/searxng:latest
    container_name: searxng
    restart: unless-stopped
    ports:
      - "127.0.0.1:8080:8080"
    volumes:
      - ./searxng:/etc/searxng:rw

volumes:
  open-webui-data:

web検索のSearXNGのためのyaml、searxng/settings.ymlを作成する。

nano searxng/settings.yml
use_default_settings: true

server:
  bind_address: "0.0.0.0"
  port: 8080
  secret_key: "local-dev-change-this-secret-key"
  limiter: false
  image_proxy: false

search:
  formats:
    - html
    - json

Docker

yamlファイルを作成した後、次のコマンドを実行する。dockerが入っていない場合はインストールしておく。

docker compose down
docker compose up -d

確実にYAMLの設定を反映したい場合は、初期化する。

docker compose down -v
docker compose up -d

Open WebUIでの設定

Open WebUIの管理画面でWeb検索の設定をする。検索結果数などは動かしながら好みで設定する。この設定をしないとWeb検索をしてくれない。

ウェブ検索: ON
ウェブ検索エンジン: searxng
Searxng クエリ URL:
http://searxng:8080/search?q=<query>&format=json

検索結果数: 5
同時リクエスト: 5

LLMの設定

LLMによってはエージェント向きの設定になっておりチャットボットに向いていない状態であったり、Web検索の結果から論述するのに向いていない設定の場合がある。その場合は、コンテキスト長、出力サイズ、温度設定などを調整する必要がある。また、プロンプトでWeb検索を使っても、単にウェブサイトの内容をまとめず、内容に基づき論じるように指示する必要もあるだろう。

設定例(modelfile)

# qwen3.6 27B / Q4_K_M / agentic coding向け
FROM qwen3.6:27b-mtp-q4_K_M

# エージェント用途ほど長くする必要はないが、念のため長くする。
PARAMETER num_ctx 65536

# 長めにしないと出力が途切れる可能性がある。
PARAMETER num_predict 8192

PARAMETER temperature 0.75
PARAMETER top_p 0.9
#PARAMETER repeat_penalty 1.05

プロンプト例(用途によっては、使わなくて良い。)

あなたは調査レポートを書くリサーチアシスタントです。
Web検索結果は最終回答の素材であり、回答を短く制限するものではありません。
検索結果をそのまま箇条書き要約するのではなく、情報を統合し、重要度順に構造化し、背景・原因・影響・限界を説明してください。
不明な点は不明と明記しつつ、利用可能な根拠から妥当な推論を示してください。
3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?