问题
Problem:
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
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
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?
Currently using:
Apache Solr 4.5.0
AJAX Solr (mainly leveraging the PagerWidget and ResultsWidget - no Facets)
回答1:
Your setup looks like this
<Browser> -> <www.mywebapp.com> -> [Firewall] -> 12.34.56.789 (Solr)
This would mean that your browser cannot access your solr instance, so AjaxSolr will not work.
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
Thus your javascript can access Solr via mywebapp.com
.
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.
Edit 1:
You may not need a reverse proxy if you can handle rules at your DNS/ Load balance.
I have used Cloudflare (https://cloudflare.com) to handle such rules.
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.
来源:https://stackoverflow.com/questions/20340220/how-to-use-proxyurl-parameter-via-ajax-solr