How to access Solr from an external IP address?

2020-06-25 18:56发布

问题:

I have Solr running on my server on localhost in the Jetty container.

This seems like an obvious question, but how do I access the web interface from outside the server itself, like from an external IP address? Obviously, authentication will be important as part of any solution.

I am also running Apache2 on the server, if that is a good solution. I'm surprised I can't find anything about this.

回答1:

I finally stumbled upon an answer to this. I don't really need persistent access to the Solr admin panel, so I can easily access it using local port forwarding in SSH.

All I had to do was run the following from a terminal on my local machine:

ssh -L 8983:localhost:8983 mlissner@IP-OF-SERVER-RUNNING-SOLR -N

And then open my browser to http://localhost:8983/solr/

Much easier than setting up an Apache config, doing proxies, and whatever else.



回答2:

It depends on your Jetty ContextPath. For example:

    ....
    WebAppContext explorerWebapp = new WebAppContext();
    explorerWebapp.setContextPath("/solr");
    ....

and then just navigate to your index:

    http://localhost:PORT/solr/