ollama-python
ollama-python copied to clipboard
Client fails to query resources behind reverse proxy path
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.
Quick fix: Open _client.py
and replace the last line with:
path = split.path or ''
return f'{scheme}://{host}:{port}{path}'
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 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
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.