configuring jetty to accept connections from only certain IP addresses

10,199

Solution 1

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

Solution 2

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

Share:
10,199

Related videos on Youtube

Saqib Ali
Author by

Saqib Ali

UI/UX Designer for an open source Ideas Bank

Updated on September 18, 2022

Comments

  • Saqib Ali
    Saqib Ali almost 2 years

    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
    Saqib Ali over 11 years
    can you please give me some examples? I am new to iptables/xinetd. Thanks.
  • fuero
    fuero over 11 years
    Have a look at this