Scenario: You have tomcat server applications (http://localhost:8080/app/, etc)which need to be placed behind a apache server. In this example apache port is 9090. You can have your own ports.
First download WampServer2.0i file and install in your machine.
Start Wamp and start apache service (Click on wamp icon in toolbar and go to apache-Service-Start/Resume Service )
In you wamp installation directory go to it's apache module and open httpd.conf file. (WAMP_HOME\bin\apache\Apache2.2.11\conf\httpd.conf)
1. Here you have to enable following modules.
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
Search them in httpd.conf file and uncomment them. (Remove # mark infront of each module entry)
Now restart Apache (Click on wamp icon in toolbar and go to apache-Service-Restart Service )
Veryfy whether modules are enabled
Click on Wamp icon and go to Apache-Apache Modules.
Check whether above modules are marked as enabled (If not by clicking on each module enable them and restart wamp)
Now you have enabled the required modules.
2. Add following line to the httpd.conf file
3. Now add theproxy stanza as follows to httpd.conf
Order deny,allow Allow from all
4. Then you have to enable URL rewriting as follows
5. For each server which need to be placed behind apahe server add a ProxyPass statement as follows. In here proxydemo is the namespace for the application access.
ProxyPass /proxydemo/ http://localhost:8080/app/
6. For each ProxyPass statement add ProxyPassReverse statement to rewrite Location headers information before passing redirect response back to the client.
ProxyPassReverse /proxydemo/ http://localhost:8080/app/
7. To avoid 404 errors after URL without ending slash add the following line to httpd.conf
RewriteRule ^/proxydemo$ /proxydemo/ [R]
Now You have done proxypassing.
Here after when you access apachserver proxypass proxydemo by http://localhost:9090/proxydemo , it will redirect to http://localhost:8080/app/ but actual URL is hidden from outside.
Imagine now you have service.jsp file in http://localhost:8080/app/service.jsp . To access this through Proxy the URL for outside will be http://localhost:9090/proxydemo/service.jsp.
Please ask if you got any problems.
In my next post apache load balancing for tomcat server will be discussed with an example.