My solr service works without HTTP authentication, but my webhost provides it and I'd like to take advantage of it.
I've been given a username and password to access my solr service by dotcloud in the form of a url:
'http://dotcloud:XXXXXXXXXXXXXXXXXXXX@gigsmash-teamfoobar.dotcloud.com/solr/'
When I point my browser to this address, it works just fine.
In my settings.py file I have the following line:
HAYSTACK_SOLR_URL = 'http://dotcloud:XXXXXXXXXXXXXXXXXXX@gigsmash-teamfoobar.dotcloud.com/solr/'
but when I run ./manage.py build_solr_schema, I get the following error:
ValueError: invalid literal for int() with base 10: 'XXXXXXXXXXXXXXXXXX@gigsmash-teamfoobar.dotcloud.com'
I don't have any problem building a schema if I remove the URL, but then I am unable to build an index ("Error 401: UNAUTHORIZED") which, of course, makes sense.
I can't find anything in the haystack docs that talks about authentication. This seems like something that would be solved by an extra couple of lines in settings.py like:
HAYSTACK_SOLR_USER = 'dotcloud'
HAYSTACK_SOLR_PSSWD = 'XXXXXXXXXXXXXXXXXXX'
but, no dice. A complete list of the Haystack settings reveals nothing along those lines: http://docs.haystacksearch.org/dev/settings.html .
Any ideas??
Thanks.
I ran into the same issue on dotcloud. The error actually isn't in Haystack -- it's in pysolr. Pysolr assumes that if there's a colon in the url, everything after it must be a port number.
One short term fix would be to use the following config on your dotcloud solr service to disable authentication:
config: solr_authentication: false
I would only do this in a dev environment and if you have data up there that isn't sensitive (since anybody could get to that url). The ultimate solution is to patch pysolr.
来源:https://stackoverflow.com/questions/7492694/solr-authentication-using-django-haystack