0

I am trying to configure Apache webserver with Tomcat using AJP, but I am not sure am I doing it right or not.

Here are the steps that I followed:

Enabled requiredModule in httpd.conf file

LoadModule proxy_module modules/mod_proxy.so  
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so  

Added the ifModule condition in httpd.conf file

<IfModule mod_proxy>  
    ProxyPass / ajp://localhost:8009/  
    ProxyPassMatch ^(/photos/.*\.jpg)$!  
</IfModule>  


Alias /photos "F:\projects\AL\Photos"  


<Directory "F:\projects\AL\Photos">  
    Options Indexes MultiViews  
    AllowOverride None  
    Order allow,deny  
    Allow from all  
</Directory> 

And finally, added the Connector in the server.xml file for Tomcat

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

Now, I am trying to browse to a JSP file at the following location:

http://localhost:8009/examples/jsp/jsp2/el/basic-arithmetic.jsp

This works fine, but I want to instead browse the JSP at:

http://localhost/examples/jsp/jsp2/el/basic-arithmetic.jsp. 

I also tried this:

<IfModule mod_proxy>

    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / ajp://localhost:8009/
    ProxyPassMatch ^(/photos/.*\.jpg)$!

    Alias /photos "F:\projects\AL\Photos"

    < Directory "F:\projects\AL\Photos">
        Options Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

</IfModule>

and then I tried to browse the following url

http://localhost/examples/jsp/jsp2/el/basic-arithmetic.jsp

which also does not work.

Have I done it right or there is something else that I can do?

rene
  • 41,474
  • 78
  • 114
  • 152
x.509
  • 2,205
  • 10
  • 44
  • 58

3 Answers3

1

Use the <Location> directive.

As in: http://stuff.mit.edu/afs/athena/project/stellar-dist/www/stellar2/apache2/stellar2-ajp-proxy.conf

NOTE: It is very important to add the "/" after ending your ajp path, else the configuration will throw a 404 error.

sth
  • 222,467
  • 53
  • 283
  • 367
0

You will also need the 'proxypassreverse' just after 'proxypass'

Ryan Fernandes
  • 8,238
  • 7
  • 36
  • 53
0

Have you enabled the AJP connector in Tomcat's server.xml:

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

You aren't supposed to use AJP port for accessing Tomcat. You can, if you want to, have both an HTTP (8080) and an AJP (8009) connector. In that case you will access Tomcat directly in localhost:8080

Also, as Ryan Fernandes said, you also need the ProxyPassReverse directive.

kgiannakakis
  • 103,016
  • 27
  • 158
  • 194