Client fails to query resources behind reverse proxy path #64

Closed
opened 2026-02-15 16:27:49 -05:00 by yindo · 4 comments
Owner

Originally created by @jpsullivan on GitHub (Apr 5, 2024).

The _parse_host method seems to be stripping off the end of URLs that Ollama may be proxied behind. For example, if I have a rule setup in Caddy/Nginx ro forward Ollama to http://localhost:8080/ollama, the client returns "http://localhost:8080", which causes all API requests to fail as the URL is technically invalid.

Originally created by @jpsullivan on GitHub (Apr 5, 2024). The `_parse_host` method seems to be stripping off the end of URLs that Ollama may be proxied behind. For example, if I have a rule setup in Caddy/Nginx ro forward Ollama to http://localhost:8080/ollama, the client returns "http://localhost:8080", which causes all API requests to fail as the URL is technically invalid.
yindo closed this issue 2026-02-15 16:27:49 -05:00
Author
Owner

@DJ4ddi commented on GitHub (Apr 11, 2024):

Quick fix: Open _client.py and replace the last line with:


  path = split.path or ''

  return f'{scheme}://{host}:{port}{path}'
@DJ4ddi commented on GitHub (Apr 11, 2024): Quick fix: Open `_client.py` and replace the last line with: ```py path = split.path or '' return f'{scheme}://{host}:{port}{path}' ```
Author
Owner

@trollkarlen commented on GitHub (May 22, 2024):

Is there a fix for this in the pipe ?

Also headers for auth and more in a proxy framework would be nice to add.

@trollkarlen commented on GitHub (May 22, 2024): Is there a fix for this in the pipe ? Also headers for auth and more in a proxy framework would be nice to add.
Author
Owner

@bplunkert commented on GitHub (May 29, 2024):

@trollkarlen I've opened up #170 following the suggestion by @DJ4ddi. I've tested and can confirm this seems to resolve the issue for me.

You can test it out in requirements.txt:

ollama @ git+https://github.com/inferret/ollama-python.git@add_url_path
@bplunkert commented on GitHub (May 29, 2024): @trollkarlen I've opened up #170 following the suggestion by @DJ4ddi. I've tested and can confirm this seems to resolve the issue for me. You can test it out in `requirements.txt`: ``` ollama @ git+https://github.com/inferret/ollama-python.git@add_url_path ```
Author
Owner

@kttalley commented on GitHub (Jun 30, 2024):

I believe I'm facing this same exact issue with my Windows 10 Apache server. It'd be great to get this fix for folks running multiple services from one server/domain, or for those wanting to isolate ollama to a specific sub-domain instead of dedicating the root.

@kttalley commented on GitHub (Jun 30, 2024): I believe I'm facing this same exact issue with my Windows 10 Apache server. It'd be great to get this fix for folks running multiple services from one server/domain, or for those wanting to isolate ollama to a specific sub-domain instead of dedicating the root.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#64