views:

457

answers:

2

Hi all,

I'd setup Apache 2.2 with Mod_Jk so that all Tomcat 6 pages is piped through Apache, port 80. Everything work fine, all pages look good.

My question is: How can I close the port 8080 listened by Tomcat ? Since right now all pages are served from port 80 by Apache, the port 8080 from Tomcat should not be accessed by end-user. I don't have hardware or software firewall in the front to block port 8080.

A: 

In Tomcats' server.xml file, you are going to want to comment out the connector that references port 8080. Typically it would look something like:

<Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" />

Comment it out, restart and that should do it.

<!-- <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" /> -->
Colin Harrington
Will this still allow Apache to connect to tomcat? Doesn't mod_jk connect via port 8080?
Andrew
Andrew, This comments out the http connector, but the AJP one should still be open allowing mod_jk to connect to it.
Colin Harrington
+1  A: 

I don't know if you can disable it completely. But you can bind it to a specific address. I.E. 127.0.0.1, so it can only be accessed from localhost.

Here's how:

<Connector port="8080" address="127.0.0.1" maxHttpHeaderSize="8192"
maxThreads="15" minSpareThreads="2" maxSpareThreads="7"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
compression="on" compressionMinSize="0"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml" />
Pablo Santa Cruz
Probably the best route. Tomcat must listen on some port and this does that, albeit only on the loopback interface.
Josh Hight