Apache / Tomcat port information

28,739

Solution 1

Ok, I'll try answering you.

Consider Apache HTTPD and Apache Tomcat two friends (I'll call them in short HTTPD and Tomcat). Each of them has means of comunicating with other people, let's say by mobile phone and lineland phone or IM.

Tomcat has three phones for recieving calls:

  • One for recieving international calls in which he speaks the langauage spoken by most people in the (informatic) world, HTTP. This phone has an international agreed subnumber (port) which is 80, but can be any number. It happens that Tomcat being a bit eccentric preferes 8080 by default, so you can speak him HTTP at port 8080 by default.

  • Another phone for recieving calls from international VIP people, which want to be ultra sure they are speaking with Tomcat and nobody can listen their call, so they speak the previous international language but switching words (encryption, HTTPS). By international agreements this port is 443, but as we said Tomcat is eccentric, he chooses for this port 8443.

  • The third Tomcat's phone he uses it to recieve calls only from people that speak his own language, AJP (He lives in Java Application Server Country). By International Common Law, it's port 8009.

HTTPD has only two phones for recieving calls

  • The first two are the same as for Tomcat but HTTPD is not that eccentric prefering to use the normal agreed numbers, 80 for HTTP and 443 for HTTPS.

The story

Now HTTPD has a shop. Sometimes costumers ask for stuff not present in the shop but when he knows Tomcat has it he calls Tomcat and asks him to bring the things.For speaking with Tomcat HTTPD can use international languages, HTTP and HTTPS, but often Tomcat is more happy to speak his own language, AJP. So HTTPD knows that there are two translators that can help him speak AJP with Tomcat, mod_jk (http://tomcat.apache.org/connectors-doc/) and mod_proxy_ajp (https://httpd.apache.org/docs/2.4/mod/mod_proxy_ajp.html).

Now being more serious, by default, HTTPD listens on ports 80 for HTTP and port 443 for HTTPS.

Tomcat listens on port 8080 for HTTP, port 8443 for https and port 8009 for AJP.

You can configure the ports for HTTPS using Listen directives in it's configuration file, httpd.conf or files included from it. So grep for Listen to check them.

You can configure Tomcat for the ports in server.xml. In Tomcat language those are connectors (as opposed to Listen in HTTPD). And as for your configuration, if you setup Tomcat to use HTTPS he will redirect requests in HTTP to the port configured.

Keep in mind, HTTPD keeps care of his ports, Tomcat of his own ports and a port can be in listen only from a single application at a time. So if you have both HTTPD and Tomcat in the same machine, they fit nicely, as the ports used are different by default:

HTTPD: Ports 80 and 443

Tomcat: Ports 8080 8443 and 8009.

Solution 2

1) Apache HTTPD server and the Tomcat web server can be connected using The Apache Tomcat Connector - mod_jk

When you will configure mod_jk on Apache HTTPD server using the following link you will see the connection: http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html The default port is 8009, but it can be changed on both sides: in server.xml on the Tomcat side and in the file worker.properties on the Apache HTTPD server side (look for 8009): http://tomcat.apache.org/connectors-doc/reference/workers.html

The configuration of Tomcat web server should be performed in addition to the workers configuration. If you will not configure the AJP Connector at Tomcat the AJP connection will not work: http://tomcat.apache.org/tomcat-7.0-doc/config/ajp.html

2) The Apache Tomcat Connector - mod_jk is started by Apache HTTPD server.

3) The redirectPort is not relevant to AJP. See below: http://tomcat.apache.org/tomcat-7.0-doc/config/http.html

If this Connector is supporting non-SSL requests, and a request is received for which a matching  requires SSL transport, Catalina will automatically redirect the request to the port number specified here.
Share:
28,739

Related videos on Youtube

Kanagavelu Sugumar
Author by

Kanagavelu Sugumar

love to be a problem solver & be a designer..

Updated on September 18, 2022

Comments

  • Kanagavelu Sugumar
    Kanagavelu Sugumar over 1 year

    I have few questions regarding the Apache HTTPD server and the Tomcat web server port configurations.

    Through netstat and TOMCAT/conf/server.xml I understand that:

    • 80 and 443 ports are used by Apache for HTTP and HTTPS requests respectively.
    • 8080 and 8443 ports are used by Tomcat for HTTP and HTTPS requests respectively.
    • There is one more Connector port="8009" using the "AJP/1.3" protocol. (AJP connector is used for cases where you wish to invisibly integrate Tomcat 4 into an existing (or new) Apache installation)

    However:

    1. How is the 8009 port interrelated with the Apache and Tomcat ports? Does this mean how the requests are interchanged between the connector, Apache, Tomcat, etc.?

    2. What is starting this AJP connector (Tomcat or Apache)?

      Because even when Apache is started; I am NOT seeing a socket listening at 8009. But this is the port mentioned at apache2/conf/workers.properties.

      I think after Tomcat is started this port is available.

    3. In server.xml what is the purpose of redirectPort 8443?

    <Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    
    • Admin
      Admin about 11 years
      Did you see the answer below? Was it helpful?
  • Michael
    Michael about 11 years
    I have updated the answer - see if it answers your questions.
  • Poutrathor
    Poutrathor about 5 years
    I think there is also the 8005 port when stopping tomcat, isn't it ?
  • Fredi
    Fredi about 5 years
    That's correct, but the question was about the other ports. And personally i just disable that, as kill works fine :-)