[GH-ISSUE #8834] [>= 0.5.5] Ollama requiring a Key for Bearer auth via header to connect is failing to load models #69884

Closed
opened 2026-05-13 02:10:23 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @mbentley on GitHub (Jan 23, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/8834

Installation Method

Running the docker images from ghcr.io/open-webui/open-webui

Environment

  • Open WebUI Version: [e.g., v0.3.11] v0.5.5 and v0.5.6

  • Ollama (if applicable): [e.g., v0.2.0, v0.1.32-rc1] 0.5.7

  • Operating System: [e.g., Windows 10, macOS Big Sur, Ubuntu 20.04] Linux (docker images from ghcr.io/open-webui/open-webui)

  • Browser (if applicable): [e.g., Chrome 100.0, Firefox 98.0] n/a

Confirmation:

  • I have read and followed all the instructions provided in the README.md.
  • I am on the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.

Expected Behavior:

I expect that the models are able to be loaded.

Actual Behavior:

The models do not load and an error is seen in the container logs:

INFO  [open_webui.routers.ollama] get_all_models()
ERROR [open_webui.routers.ollama] Connection error: 401, message='Attempt to decode JSON with unexpected mimetype: application/octet-stream', url='https://ollama.casa.mbentley.net/api/tags'

Description

Bug Summary:

Reproduction Details

Steps to Reproduce:

Configure Ollama with nginx reverse proxy with auth using a bearer token auth header:

# ollama
upstream ollama_http {
  server 127.0.0.1:11434;
}

...
   location / {
     # Check if the Authorization header is present and has the correct Bearer token / API Key
     set $token "Bearer setrandomtokenhereforauth";
     if ($http_authorization != $token) {
       return 401 "Unauthorized";
     }

     proxy_set_header Host "localhost";
     proxy_set_header X-Real-IP "127.0.0.1";
     proxy_set_header X-Forwarded-For "127.0.0.1";
     proxy_set_header X-Forwarded-Proto $scheme;
     proxy_pass http://ollama_http;
   }

Happy to provide more details on this configuration, if needed.

Logs and Screenshots

I have my ollama connection pointing to my nginx instance and the key passed for the bearer auth:
Image

Browser Console Logs:
n/a

Docker Container Logs:

When saving the connection settings dialog, the following error shows where it seems that it is not attempting to pass the bearer header when accessing the /api/tags endpoint.

INFO  [open_webui.env] Saving 'ENABLE_OLLAMA_API' to the database
INFO  [open_webui.env] Saving 'OLLAMA_BASE_URLS' to the database
INFO  [open_webui.env] Saving 'OLLAMA_API_CONFIGS' to the database
INFO  [open_webui.env] Saving 'OLLAMA_API_CONFIGS' to the database
INFO:     192.168.0.1:0 - "POST /ollama/config/update HTTP/1.0" 200 OK
INFO  [open_webui.routers.ollama] get_all_models()
ERROR [open_webui.routers.ollama] Connection error: 401, message='Attempt to decode JSON with unexpected mimetype: application/octet-stream', url='https://ollama.casa.mbentley.net/api/tags'
INFO:     192.168.0.1:0 - "GET /api/models HTTP/1.0" 200 OK

Screenshots/Screen Recordings (if applicable):

I then have no models showing on my instance with model access control disabled:

Image

Additional Information

This worked before using 0.5.4 and earlier. If I set the API endpoint for /api/tags to not require auth, it seems that everything works fine but I don't think it is expected to have to do so.

Originally created by @mbentley on GitHub (Jan 23, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/8834 ## Installation Method Running the docker images from `ghcr.io/open-webui/open-webui` ## Environment - **Open WebUI Version:** [e.g., v0.3.11] `v0.5.5` and `v0.5.6` - **Ollama (if applicable):** [e.g., v0.2.0, v0.1.32-rc1] `0.5.7` - **Operating System:** [e.g., Windows 10, macOS Big Sur, Ubuntu 20.04] Linux (docker images from `ghcr.io/open-webui/open-webui`) - **Browser (if applicable):** [e.g., Chrome 100.0, Firefox 98.0] n/a **Confirmation:** - [X] I have read and followed all the instructions provided in the README.md. - [X] I am on the latest version of both Open WebUI and Ollama. - [X] I have included the browser console logs. - [X] I have included the Docker container logs. - [X] I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below. ## Expected Behavior: I expect that the models are able to be loaded. ## Actual Behavior: The models do not load and an error is seen in the container logs: ``` INFO [open_webui.routers.ollama] get_all_models() ERROR [open_webui.routers.ollama] Connection error: 401, message='Attempt to decode JSON with unexpected mimetype: application/octet-stream', url='https://ollama.casa.mbentley.net/api/tags' ``` ## Description **Bug Summary:** ## Reproduction Details **Steps to Reproduce:** Configure Ollama with nginx reverse proxy with auth using a bearer token auth header: ``` # ollama upstream ollama_http { server 127.0.0.1:11434; } ... location / { # Check if the Authorization header is present and has the correct Bearer token / API Key set $token "Bearer setrandomtokenhereforauth"; if ($http_authorization != $token) { return 401 "Unauthorized"; } proxy_set_header Host "localhost"; proxy_set_header X-Real-IP "127.0.0.1"; proxy_set_header X-Forwarded-For "127.0.0.1"; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://ollama_http; } ``` Happy to provide more details on this configuration, if needed. ## Logs and Screenshots I have my ollama connection pointing to my nginx instance and the key passed for the bearer auth: ![Image](https://github.com/user-attachments/assets/a542ad0e-d096-4e6b-9f60-eed27bbeeead) **Browser Console Logs:** n/a **Docker Container Logs:** When saving the connection settings dialog, the following error shows where it seems that it is not attempting to pass the bearer header when accessing the `/api/tags` endpoint. ``` INFO [open_webui.env] Saving 'ENABLE_OLLAMA_API' to the database INFO [open_webui.env] Saving 'OLLAMA_BASE_URLS' to the database INFO [open_webui.env] Saving 'OLLAMA_API_CONFIGS' to the database INFO [open_webui.env] Saving 'OLLAMA_API_CONFIGS' to the database INFO: 192.168.0.1:0 - "POST /ollama/config/update HTTP/1.0" 200 OK INFO [open_webui.routers.ollama] get_all_models() ERROR [open_webui.routers.ollama] Connection error: 401, message='Attempt to decode JSON with unexpected mimetype: application/octet-stream', url='https://ollama.casa.mbentley.net/api/tags' INFO: 192.168.0.1:0 - "GET /api/models HTTP/1.0" 200 OK ``` **Screenshots/Screen Recordings (if applicable):** I then have no models showing on my instance with model access control disabled: ![Image](https://github.com/user-attachments/assets/f2b19fd6-5502-42b6-ae96-840723497a52) ## Additional Information This worked before using 0.5.4 and earlier. If I set the API endpoint for `/api/tags` to not require auth, it seems that everything works fine but I don't think it is expected to have to do so.
Author
Owner

@tjbck commented on GitHub (Jan 23, 2025):

You might want to try the latest main!

<!-- gh-comment-id:2610756413 --> @tjbck commented on GitHub (Jan 23, 2025): You might want to try the latest main!
Author
Owner

@mbentley commented on GitHub (Jan 23, 2025):

Ah shoot, I was looking at the commits against 6c8d68b6fc/backend/open_webui/routers/ollama.py and thought I had compared the date of that last commit to the v0.5.6 release but I apparently can't read 😆

The latest main does indeed fix it. Thanks for the quick reply!

<!-- gh-comment-id:2610775982 --> @mbentley commented on GitHub (Jan 23, 2025): Ah shoot, I was looking at the commits against https://github.com/open-webui/open-webui/commits/6c8d68b6fc4ba25f02627c21552a726c0bd2b36e/backend/open_webui/routers/ollama.py and thought I had compared the date of that last commit to the v0.5.6 release but I apparently can't read 😆 The latest `main` does indeed fix it. Thanks for the quick reply!
Author
Owner

@mbentley commented on GitHub (Jan 23, 2025):

@tjbck - spoke too soon. the models load on the latest main image but chats fail:

Image

INFO:     192.168.0.1:0 - "GET /api/v1/users/user/settings HTTP/1.0" 200 OK
INFO:     192.168.0.1:0 - "GET /api/v1/users/user/settings HTTP/1.0" 200 OK
INFO:     192.168.0.1:0 - "POST /api/v1/chats/new HTTP/1.0" 200 OK
INFO:     192.168.0.1:0 - "GET /api/v1/chats/?page=1 HTTP/1.0" 200 OK
INFO:     192.168.0.1:0 - "POST /api/v1/chats/759551dc-03a4-4746-b893-a7d09e27579a HTTP/1.0" 200 OK
INFO:     192.168.0.1:0 - "GET /api/v1/chats/?page=1 HTTP/1.0" 200 OK
INFO:     192.168.0.1:0 - "POST /api/chat/completions HTTP/1.0" 400 Bad Request
INFO:     192.168.0.1:0 - "GET /api/v1/chats/?page=1 HTTP/1.0" 200 OK

If you would prefer that I open a new issue, I can. Rolling back to 0.5.4, chats work as expected.

*edit: disregard - 0.5.7 works fine now.

<!-- gh-comment-id:2610820037 --> @mbentley commented on GitHub (Jan 23, 2025): @tjbck - spoke too soon. the models load on the latest `main` image but chats fail: ![Image](https://github.com/user-attachments/assets/157f6af7-4d9f-4944-ace8-61613f3b6418) ``` INFO: 192.168.0.1:0 - "GET /api/v1/users/user/settings HTTP/1.0" 200 OK INFO: 192.168.0.1:0 - "GET /api/v1/users/user/settings HTTP/1.0" 200 OK INFO: 192.168.0.1:0 - "POST /api/v1/chats/new HTTP/1.0" 200 OK INFO: 192.168.0.1:0 - "GET /api/v1/chats/?page=1 HTTP/1.0" 200 OK INFO: 192.168.0.1:0 - "POST /api/v1/chats/759551dc-03a4-4746-b893-a7d09e27579a HTTP/1.0" 200 OK INFO: 192.168.0.1:0 - "GET /api/v1/chats/?page=1 HTTP/1.0" 200 OK INFO: 192.168.0.1:0 - "POST /api/chat/completions HTTP/1.0" 400 Bad Request INFO: 192.168.0.1:0 - "GET /api/v1/chats/?page=1 HTTP/1.0" 200 OK ``` If you would prefer that I open a new issue, I can. Rolling back to `0.5.4`, chats work as expected. *edit: disregard - 0.5.7 works fine now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#69884