如何通过AJAX Solr使用proxyUrl参数 [英] How to use proxyUrl parameter via AJAX Solr
问题描述
我有一个Solr 4.5.0实例,该实例位于无法直接由公众访问的私有服务器上,
I have a Solr 4.5.0 intance that lives on a private server not directy accessible to the public,
12.34.56.789:8983/solr/collection1/select?q=*%3A*&wt=json&indent=true
一旦从该Solr实例检索到JSON,我就利用JavaScript框架AJAX Solr呈现搜索结果.用户界面显示在这里,
I am leveraging JavaScript framework AJAX Solr to present the search results once the JSON is retrieved from that Solr instance. The UI is presented here,
www.mywebapp.com/searchresults.html
请注意:
Please note:
www.mywebapp.com
can access...
12.34.56.789
我已经探究了代理的建议,似乎AJAX Solr附带了一个使我能够执行此操作的参数. JS库不是对库进行硬编码以直接调用Solr(由于Cross Origin的限制而无法使用),而是在 proxyUrl 中建议了一种替代方法.
I've explored the suggestion for proxying and it seems as though AJAX Solr comes with a parameter that would enable me to do that. Instead of hardcoding the library to call Solr directly (which won't work because of Cross Origin restrictions), the JS library suggests an alternative in proxyUrl.
//Per AbstractManager.js
solrUrl: 'http://12.34.56.789:8983/solr/'
proxyUrl: null
是否有任何资源,教程,分步指南可以概述如何成功使用该参数?
Are there any resources, tutorials, step-by-step guides that could outline how to successfully use that parameter?
Apache Solr 4.5.0
AJAX Solr(主要利用PagerWidget和ResultsWidget-无方面)
Apache Solr 4.5.0
AJAX Solr (mainly leveraging the PagerWidget and ResultsWidget - no Facets)
推荐答案
您的设置如下
<Browser> -> <www.mywebapp.com> -> [Firewall] -> 12.34.56.789 (Solr)
这意味着您的浏览器无法访问您的solr实例,因此AjaxSolr无法正常工作.
This would mean that your browser cannot access your solr instance, so AjaxSolr will not work.
您可以尝试通过www.mywebapp.com代理请求,而不是使用proxyUrl.
Instead of using proxyUrl, you can try proxying your requests via www.mywebapp.com.
即设置反向代理以进行路由
I.e setup a reverse proxy to route
http://www.mywebapp.com/solr -> http://12.34.56.789/solr
因此,您的JavaScript可以通过mywebapp.com
访问Solr.
Thus your javascript can access Solr via mywebapp.com
.
然后将您的AjaxSolr设置更改为
Then change your AjaxSolr setting to
solrUrl: 'http://www.mywebapp.com/solr'
最重要的是,您需要一个可从浏览器访问的端点.
Bottom line is you need an endpoint that is accessible from the browser.
如果您可以在DNS/负载平衡下处理规则,则可能不需要反向代理.
You may not need a reverse proxy if you can handle rules at your DNS/ Load balance.
我已经使用Cloudflare( https://cloudflare.com )处理此类规则.
I have used Cloudflare (https://cloudflare.com) to handle such rules.
如果这不是一个选项,则可以使用反向代理.有很多选择,我更喜欢nginx. 此处是说明将nginx设置为反向的文章代理人.
In case that is not an option, you can use a reverse proxy. There are quite a few options for this, I prefer nginx. Here is an article that explains setting up nginx as reverse proxy.
这篇关于如何通过AJAX Solr使用proxyUrl参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!