0

Im using mod_proxy_ajp to redirect from Apache to Tomcat. Apache is runnig on port 80 and tomcat ajp connector set on port 8081. here is my virtual host configuration:

<virtualHost *:80>
   ServerName www.example.com
   ProxyRequests Off
   ProxyPreserveHost On

   <Proxy *>
      AddDefaultCharset Off
      Order deny,allow
          Allow from all
   </Proxy>

   ProxyPass / ajp://localhost:8081/example/
   ProxyPassReverse / ajp://localhost:8081/example/

   <Location />
    Order allow,deny
    Allow from all
   </Location>
</VirtualHost>

The problem is when i type url www.example.com ( example is in tomcat webapp directory) only the title of example app loads and the browser stop loading and nothing happens. any idea? Thanks and sorry for my poor english

zhozhe
  • 103
  • 2

1 Answers1

0

In the default configuration, the 8080 port serves HTTP content, and AJP is served using the 8009 port. You can confirm this in tomcat's server.xml file, an example:

<Executor name="tomcatThreadPool" 
          namePrefix="catalina-exec-"
          maxThreads="150" 
          minSpareThreads="4"/>

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

<Connector executor="tomcatThreadPool"
           port="8009" protocol="AJP/1.3"
           connectionTimeout="20000"
           URIEncoding="UTF-8"
           redirectPort="8443" />

mod_proxy_ajp does not require a ProxyPassReverse directive, so you can simply replace:

ProxyPass / ajp://localhost:8081/example/
ProxyPassReverse / ajp://localhost:8081/example/

with:

ProxyPassMatch ^/(example)(.*) ajp://localhost:8009/$1$2 ttl=120 ping=1

in the Apache configuration. Use the appropriate port for AJP.

dawud
  • 14,918
  • 3
  • 41
  • 61
  • Tnx Man! Its worked! – zhozhe Jul 13 '13 at 21:28
  • Sorry man but now i have another problem... how can i remove (example) from ProxyPassMath? because in this way i should type url like www.example.com/example ! but i just want to use www.example.com – zhozhe Jul 13 '13 at 23:07
  • I did that but the problem came back again! the browser just load the title and then nothing happens! – zhozhe Jul 14 '13 at 09:44
  • the problem is still here...just title loads :( – zhozhe Jul 14 '13 at 11:10
  • I don't really know what does it mean that "only title loads". I have shown several different ways to proxy traffic through apache to tomcat. – dawud Jul 14 '13 at 11:48
  • i mean only the application title in the browser loads and the page stays blank... – zhozhe Jul 14 '13 at 12:20