Search code examples
dockerdocker-composeollamawebuisearxng

Error while enabling the Searxng as web search engine in Open Web UI


I want to enable seachxng - meta search engine in my Open WebUI (formerly Ollama Web UI).

I have written the docker compose file as below but the problem is, when I open Open Web UI and selected the 'searxng' as my web search option, added 'http://searxng:8080/search?q=<query>' as a searxng Query URL. After that, in the Open Web UI Chat box, I enable the Web Search option and asked the question 'who is a winner of Euro 2024?'. It gets me this error:

403 Client Error: FORBIDDEN for url: http://searxng:8080/search?q=who+is+euro+2024+winner&format=json&pageno=1&safesearch=1&language=en-US&time_range=&categories=&theme=simple&image_proxy=0

Therefore, could not get the results via web searching and got error every time.

Could you please tell me how to successfull yenable the web search engine 'searxng' in my Open Web UI?

I have written the docker-compose.yml file as below:

services:

  webui:
    image: ghcr.io/open-webui/open-webui:main
    ports:
      - 3000:8080
   
    environment:
      OLLAMA_BASE_URL: http://ollama:11434
      SEARXNG_URL: http://searxng:8088
      ENABLE_RAG_WEB_SEARCH: True
      RAG_WEB_SEARCH_ENGINE: "searxng"
      RAG_WEB_SEARCH_RESULT_COUNT: 4
      RAG_WEB_SEARCH_CONCURRENT_REQUESTS: 12
      SEARXNG_QUERY_URL: "http://searxng:8088/search?q=<query>"

    volumes:
      - open-webui:/app/backend/data
    depends_on:
     - ollama
     - searxng
    restart: always
    

  ollama:
    image: ollama/ollama:latest
    ports:
     - 11434:11434
    healthcheck:
      test: ollama --version || exit 1
    command: serve
    volumes:
      - ollama:/root/.ollama
      - ./start_ollama.sh:/start_ollama.sh
    restart: always
    entrypoint: [ "/usr/bin/bash", "/start_ollama.sh" ]

  searxng:
    image: searxng/searxng:latest
    ports:
      - "8888:8080"
    environment:
      - BASE_URL=http://searxng:8088/
    restart: always

volumes:
  open-webui:
  ollama:

Solution

  • I ran into same issue. The problem is that by default the SearXNG seems to only support format=html. I don't know what is the best way to resolve this but you can get format=json working by editing /etc/searxng/settings.yml and adding json to the enabled search formats. Would be nice to have environment variable for this for the docker image.

    search:
      # remove format to deny access, use lower case.
      # formats: [html, csv, json, rss]
      formats:
        - html
        - json
    

    This is what I successfully use with my app:

      searxng:
        container_name: searxng
        image: searxng/searxng:${SEARXNG_DOCKER_TAG-latest}
        volumes:
          - ./searxng:/etc/searxng
        ports:
          - "8080:8080"
        environment:
          - BASE_URL=http://localhost:8080
          - INSTANCE_NAME=${SEARXNG_NAME-searxng}
    

    Base url should be set properly, http://0.0.0.0:8080 might be more approppriate for container but localhost seems to work.

    I have the modified ./searxng/settings.yml given to searxng as a volume mount.

    To see if you can access the searxng, try with curl from your webui container.