Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache & Tomcat: ProxyPass and ProxyPassReverse

I'am having troubles configuring Apache and Tomcat, this is the scenario:

I have an Apache Web Server, running and working normally, I can access to this one just typing:

http://localhost

Also, in this host, I have a Tomcat running and working fine; I've created a mini web-app which files are inside "prueba" directory, I can access typing:

http://localhost:8080/prueba

(I know that Apache is running in 80 port and Tomcat in 8080)

What I want to do is that througt Apache an user can access to 'pruebas'(running on Tomcat), I mean:

http://localhost/prueba

I've readen a lot of this, and I think that there are 2 ways to do this, and I've decided enabling the proxy modules(proxy and proxy_ajp, with a2enmod), also I've readed I must edit this file: sites-available/default, this is the content:

NameVirtualHost *:80
<VirtualHost *:80>
     ServerName 127.0.0.1
     DocumentRoot /var/www

     ProxyRequests Off
     ProxyPreserveHost On

     ProxyPass /static/ !
     ProxyPass / ajp://localhost:8009/
     ProxyPassReverse / ajp://localhost:8009/

.
.
.
     Alias /static/ "/apache/www/"

</VirtualHost>

But this hasn't work propperly :(

I have to say that I've tried whit many changes, ont this 2 lines, like:

     ProxyPass /prueba ajp://localhost:8009/prueba
     ProxyPassReverse /prueba ajp://localhost:8009/prueba

or

     ProxyPass / ajp://localhost:8009/prueba
     ProxyPassReverse / ajp://localhost:8009/prueba

(each time I edit the file, I restart apache)

But when I access to [http://localhost/prueba/], I have: Service Temporarily Unavailable

Has anyone knows why? Thanks in advance guys.

Pd: I'm working with apache 2.2.17 and tomcat6.

like image 579
karlos9o Avatar asked Nov 25 '12 10:11

karlos9o


People also ask

What do you mean by Apache?

Definition of Apache 1 : a member of a group of American Indian peoples of the southwestern U.S. 2 : any of the Athabascan languages of the Apache people. 3 not capitalized [French, from Apache Apache Indian] a : a member of a gang of criminals especially in Paris. b : ruffian.

Why is Apache so popular?

Apache is open source, and as such, it is developed and maintained by a large group of global volunteers. One of the key reasons Apache is so popular is that the software is free for anyone to download and use.

Why is it called Apache?

The name 'Apache' was chosen from respect for the various Native American nations collectively referred to as Apache, well-known for their superior skills in warfare strategy and their inexhaustible endurance.

What was Apache territory?

The Apache dominated much of northern Mexico, Arizona, New Mexico, and Texas for hundreds of years. It is estimated that about 5,000 Apache lived in the Southwest in 1680 AD. Some Apache lived in the mountains, while others lived on the plains.


1 Answers

You have to put

 ProxyPass / ajp://localhost:8009/
 ProxyPassReverse / ajp://localhost:8009/

on your apache virtual host

Then you have to uncomment ajp listener in tomcat

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

Then you have to configure host and context path in server.xml

REFF: http://www.ntu.edu.sg/home/ehchua/programming/howto/ApachePlusTomcat_HowTo.html

Hope this will help you..

like image 137
Dilip Rajkumar Avatar answered Sep 26 '22 18:09

Dilip Rajkumar