How to bind Tomcat to multiple IP addresses

Solution Unverified - Updated -

Environment

  • Red Hat Enterprise Linux (RHEL)
    • 5.x
    • 6.x
  • Red Hat JBoss Enterprise Web Server (EWS)
    • 1.0.x
    • 2.0.x
  • Tomcat
    • 5.5
    • 6.0
    • 7.0

Issue

  • How do I bind Tomcat to multiple IP addresses?
  • I would like to bind Tomcat to specific two IP addresses but not to bind all IP addresses on the machine.

Resolution

If you don not specify address attribute on <Connect> setting, Tomcat bind to any IP address (*). It means Tomcat bind to all IP address on the machine by default.

If you want to configure Tomcat to bind specific IP address, you can set the IP address to address attribute. However, you can not specify multiple IP addresses to the address attribute at once.

If you want to bind multiple IP addresses but not to bind all IP addresses, you need to add new <Connector> setting with same port but different IP address. For example:

  • server.xml:

    <Connector port="8080" protocol="HTTP/1.1" 
               address="192.168.0.1"
               connectionTimeout="20000" 
               maxPostSize="2147483647" 
               redirectPort="8443" />
    <Connector port="8080" protocol="HTTP/1.1" 
               address="192.168.0.2"
               connectionTimeout="20000" 
               maxPostSize="2147483647" 
               redirectPort="8443" />
    

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments