Solr身份验证(使用Django Haystack) [英] Solr authentication (using Django Haystack)

查看:145
本文介绍了Solr身份验证(使用Django Haystack)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的solr服务无需HTTP身份验证即可工作,但我的网络主机提供了该服务,我想利用它.

My solr service works without HTTP authentication, but my webhost provides it and I'd like to take advantage of it.

dotcloud已为我提供了一个用户名和密码来访问我的solr服务:

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/'

'http://dotcloud:XXXXXXXXXXXXXXXXXXXX@gigsmash-teamfoobar.dotcloud.com/solr/'

当我将浏览器指向该地址时,它就可以正常工作.

When I point my browser to this address, it works just fine.

在我的settings.py文件中,有以下一行:

In my settings.py file I have the following line:

    HAYSTACK_SOLR_URL = 'http://dotcloud:XXXXXXXXXXXXXXXXXXX@gigsmash-teamfoobar.dotcloud.com/solr/' 

但是当我运行./manage.py build_solr_schema时,出现以下错误:

but when I run ./manage.py build_solr_schema, I get the following error:

ValueError:以10为底的int()无效文字:"XXXXXXXXXXXXXXXXXX@gigsmash-teamfoobar.dotcloud.com"

ValueError: invalid literal for int() with base 10: 'XXXXXXXXXXXXXXXXXX@gigsmash-teamfoobar.dotcloud.com'

如果删除URL,构建架构没有任何问题,但是我无法建立索引("Error 401:UNAUTHORIZED"),这当然是有道理的.

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.

我在干草堆文档中找不到任何有关身份验证的内容.这似乎可以通过settings.py中的额外几行来解决,例如:

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'

但是,没有骰子. Haystack设置的完整列表没有显示出类似的内容: http://docs.haystacksearch.org/dev/settings.html .

but, no dice. A complete list of the Haystack settings reveals nothing along those lines: http://docs.haystacksearch.org/dev/settings.html .

任何想法?

谢谢.

推荐答案

我在dotcloud上遇到了同样的问题.该错误实际上不在干草堆中-而是在pysolr中. Pysolr假定,如果URL中有一个冒号,则它后面的所有内容都必须是端口号.

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.

一个短期解决方案是在dotcloud solr服务上使用以下配置禁用身份验证:

One short term fix would be to use the following config on your dotcloud solr service to disable authentication:

config: solr_authentication:错误

config: solr_authentication: false

我只会在开发环境中执行此操作,如果那里有不敏感的数据(因为任何人都可以访问该URL).最终的解决方案是修补pysolr.

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.

这篇关于Solr身份验证(使用Django Haystack)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆