Sunday, April 10, 2022

[SOLVED] Httpd integration with Tomcat 9

Issue

I need to configure httpd with Tomcat. I tried few steps but it is not working.

1) I installed both httpd2.4 and tomcat9. Checked both individually with localhost:8080 and localhost and it works perfectly fine.
2) To configure, I did changes on httpd with below changes.

a) Uncomment below LoadModule

  LoadModule proxy_module modules/mod_proxy.so
  LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
  LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
  LoadModule proxy_connect_module modules/mod_proxy_connect.so
  LoadModule proxy_express_module modules/mod_proxy_express.so
  LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
  LoadModule proxy_http_module modules/mod_proxy_http.so

b) Added New Virtual Host

  <VirtualHost ws.foobar.com:80>
  ServerName ws.foobar.com

  ProxyRequests Off
  ProxyPass /examples ajp://localhost:8009/examples
  ProxyPassReverse /examples ajp://localhost:8009/examples
  </VirtualHost>

3) Similarly, done the changes for Tomcat and umcommented AJP connector.

    <!-- Define an AJP 1.3 Connector on port 8009 -->

<Connector protocol="AJP/1.3"
           address="::1"
           port="8009"
           redirectPort="8443" />

After doing these changes, I have changes th hosts file on my windows system as well.

  "# localhost name resolution is handled within DNS itself.
  # 127.0.0.1       localhost
  # ::1             localhost
  103.73.151.211    ws.foobar.com
   192.168.0.103    ws.foobar.com
    127.0.0.1      ws.foobar.com
     ::1            ws.foobar.com"

After doing all these changes My httpd.exe is not starting and tomcat starts but while starting giving error for AJP.

Httpd.exe from cmd

enter image description here


Solution

I myself has figured out the issue and how to configure Apache with tomcat.

I did the following changes :

  1. uncommented LoadModule proxy_module modules/mod_proxy.so & LoadModule proxy_http_module modules/mod_proxy_http.so from the httpd.conf file
  2. uncommented Include conf/extra/httpd-vhosts.conf, always in httpd.conf In httpd-vhosts.conf, I added as below. Remove the space between "< V" as somehow without space it is not displaying here in stackoverflow.

    < VirtualHost *:80>
    ServerName localhost
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass /  http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
    < /VirtualHost>
    


Answered By - user1111880
Answer Checked By - Cary Denson (WPSolving Admin)