Restricting Solr with Jetty to localhost

If you want to try Apache Solr, the easiest way to get started is to use the example the comes with the download. Just run java -jar start.jar and you can start searching like a pro.

However, the integrated Jetty server is configured to bind to port 8983 on all IP adresses by default. This configuration is unsafe: anyone could clear your whole Solr index!

It is a good idea to let the server listen only on localhost, unless your server is in a private network. A quick solution is to set the system properties jetty.host and jetty.port on startup, e.g. like that:

java -Djetty.host=127.0.0.1 -Djetty.port=1337 -jar start.jar

Alternatively, you can edit the configuration at example/etc/jetty.xml. Look for these lines:

<Set name="host"><SystemProperty name="jetty.host" /></Set>¬
<Set name="port"><SystemProperty name="jetty.port" default="8983"/></Set>

One thought on “Restricting Solr with Jetty to localhost