views:

488

answers:

5

I am trying to configuring 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 required module 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

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


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


      
        Options Indexes MultiViews  
        AllowOverride None  
        Order allow,deny  
        Allow from all  
     
  • And finally adding the connector in server.xml file of tomcat

    

Now i am trying to test to browse some JSP file at the following location


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

which is working fine. but i want to browse this file at


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

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

A: 

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

Ryan Fernandes
A: 

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
A: 
alee
ok i can't add comment properly. the entier config is surrounded by <ifmodule mod_proxy>
alee
A: 

I want apache httpd running on front and wants to forward the jsp/servlet requests to tomcat only. I want my static pages and photos to be processed by apache and want to configure it through mod_ajp

I have come up with some settings which actually helped me in forwarding the reqeust to tomcat. But now i can't add ProxyPassMatch directive to it.. here are the configurations i have done in httpd.conf file

<VirtualHost *:80>
    ServerName localhost
    <Proxy *>
        AddDefaultCharset Off
        Order deny,allow
        Allow from all
    </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>
</VirtualHost>

How can if some request is for photos, don't forward, else forward it. Suggestions?

P.S: currently i have ProxyPassMatch commented out

alee
A: 

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.

Rick Protik