ollama-python icon indicating copy to clipboard operation
ollama-python copied to clipboard

Client fails to query resources behind reverse proxy path

Open jpsullivan opened this issue 10 months ago • 4 comments

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.

jpsullivan avatar Apr 05 '24 06:04 jpsullivan

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


  path = split.path or ''

  return f'{scheme}://{host}:{port}{path}'

DJ4ddi avatar Apr 11 '24 10:04 DJ4ddi

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 avatar May 22 '24 15:05 trollkarlen

@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 avatar May 29 '24 21:05 bplunkert

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 avatar Jun 30 '24 09:06 kttalley