Change Solr base context path

2019-07-26 06:54发布

问题:

I've installed a Solr (5.3.1 and 5.5.0) in a Ubuntu machine.

With apache I've made a

ProxyPass /MySolr http://{url}:8984/solr

ProxyPassReverse /MySolr http://{url}:8984/solr

So, when I load {url}/MySolr the Dashboard doesn't load because one json.

http://{url}/solr/admin/cores?wt=json&indexInfo=false&_=...

That's normal because the correct URL to load would be:

http://{url}/MySolr/admin/cores?wt=json&indexInfo=false&_=...

When i see the other resouces, solr get the correct URL like:

http://{url}/MySolr/js/scripts/segments.js?_=5.5.0

Any idea?

回答1:

This process will not work because probably this json is specified with absolute path. In this case Solr doesn't know your mapping. If you want to change the context path you need to change this configuration on Jetty. This way solr will start using the new context. The first step is create a symbolic link MySolr pointing to solr directory (default located in $SOLR_INSTALL_DIR/server/). Now change the Jetty configuration file $SOLR_INSTALL_DIR/server/contexts/solr-jetty-context.xml to point to the new context path like this:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath"><Property name="hostContext" default="/MySolr"/></Set>
  <Set name="war"><Property name="jetty.base"/>/solr-webapp/webapp</Set>
  <Set name="defaultsDescriptor"><Property name="jetty.base"/>/etc/webdefault.xml</Set>
  <Set name="extractWAR">false</Set>
</Configure>

Now just restart Solr to be able to access using the new base context path.