This assumes you have Solr configured as explained in my post on installing Solr 3.6 on Ubuntu 12.04.
1. Make Solr accessible from outside the localhost
sudo nano /etc/default/jetty
JETTY_HOST=0.0.0.0
2. Add user authentication
sudo nano /usr/share/solr/WEB-INF/web.xml
Add this to the <web-app> section:
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Resource</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Test Realm</realm-name>
</login-config>
3. Configure jetty.xml
Ensure the following is in /etc/jetty/jetty.xml
<Set name="UserRealms">
<Array type="org.mortbay.jetty.security.UserRealm">
<Item>
<New class="org.mortbay.jetty.security.HashUserRealm">
<Set name="name">Test Realm</Set>
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
<Set name="refreshInterval">0</Set>
</New>
</Item>
</Array>
</Set>
4. Add username and password
sudo nano /usr/share/jetty/etc/realm.properties
my_username_here: MD5:md5_hash_here,user
5. Restart jetty
sudo /etc/init.d/jetty restart
You should now be prompted for a password when accessing mysite:8080/solr
Or go to http://my_username_here:my_password_here@mysite:8080/solr/