How do you configure tomcat to bind to a single ip address (localhost) instead of all addresses?
This question is tagged with
~ Asked on 2008-08-20 19:16:20
Several connectors are configured, and each connector has an optional "address" attribute where you can set the IP address.
<Connector port="8080" protocol="HTTP/1.1" address="127.0.0.1" connectionTimeout="20000" redirectPort="8443" />
~ Answered on 2008-08-20 19:19:46
it's well documented here:
How do I bind to a specific ip address? - "Each Connector element allows an address property. See the HTTP Connector docs or the AJP Connector docs". And HTTP Connectors docs:
Standard Implementation -> address
"For servers with more than one IP address, this attribute specifies which address will be used for listening on the specified port. By default, this port will be used on all IP addresses associated with the server."
~ Answered on 2013-05-26 13:17:38
It may be worth mentioning that running tomcat as a non root user (which you should be doing) will prevent you from using a port below 1024 on *nix. If you want to use TC as a standalone server -- as its performance no longer requires it to be fronted by Apache or the like -- you'll want to bind to port 80 along with whatever IP address you're specifying.
You can do this by using IPTABLES to redirect port 80 to 8080.
~ Answered on 2013-12-19 22:10:34