2

I am using the jetty that is shipped with Apache Solr to run Solr. I would like to configure jetty such that it only accepts connections from certain IP addresses. I know I can bind jetty to 127.0.0.1 to only accept connections from the localhost:

<Set name="host"><SystemProperty name="jetty.host" default="127.0.0.1" /></Set>

But how I do set it so that it can accept connections from certain non-localhost IP addresses as well?

Saqib Ali
  • 410
  • 2
  • 7
  • 19

2 Answers2

4

You can use the IPAccessHandler that is in jetty 7, 8 and 9

http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/server/handler/IPAccessHandler.html

you would wire this up in the handler chain so that it is executed before anything else in the handler chains

[edit] also look at the jetty-ipaccess.xml file under $jetty.home/etc

http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-server/src/main/config/etc/jetty-ipaccess.xml

1

You could let iptables or xinetd redirect traffic from port 8080 or 80 to the port you let jetty listen on. Both can restrict to certain IP addresses for this.

Examples can be found here

fuero
  • 9,413
  • 1
  • 35
  • 40