File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes I have trouble in setting proxy in  apache server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "I have trouble in setting proxy in  apache server" Watch "I have trouble in setting proxy in  apache server" New topic
Author

I have trouble in setting proxy in apache server

Maan Suraj
Ranch Hand

Joined: Dec 20, 2007
Posts: 299
I was basically trying to implement a sample project and following the instructions as given in the site "http://code.google.com/webtoolkit/doc/1.6/DevGuideServerCommunication.html#DevGuideRPCDeployment".My tomcat 5.5 is up and running.When i hit the URL "http://localhost:8080/stockwatcher/stockwatcher/stockPrices" i get HTTP Status 405 - HTTP method GET is not supported by this URL.I am ok with above 405 error.
Now I have installed apache tomcat2.2 (httpd-2.2.21-win32-x86-no_ssl.msi) by downloading from apache website.I want to implement reverse proxy so i do as the site says
("http://code.google.com/webtoolkit/doc/1.6/DevGuideServerCommunication.html#DevGuideRPCDeployment"). So the general idea is to setup Apache to redirect ONLY requests to your servlets. That way Apache will serve all the static content, and your Tomcat server will only be used for service calls.
Steps which i did)
1) uncommented "LoadModule proxy_module modules/mod_proxy.so" from httpd conf file
2)added
ProxyPass /stockwatcher/stockwatcher/stockPrices http://localhost:8080/stockwatcher/stockwatcher/stockPrices

in httpd.conf file
3) Remember i told earlier that when i hit "http://localhost:8080/stockwatcher/stockwatcher/stockPrices" url i get 405. That is what iexpect when i hit "localhost:80/stockwatcher/stockwatcher/stockPrices"
4)My apache tomcat runs on port 80, so i expect when i hit "localhost:80/stockwatcher/stockwatcher/stockPrices", it should redirect me to
"http://localhost:8080/stockwatcher/stockwatcher/stockPrices"
5)My apache tomcat comes up fine,because when i try to access static content,it displays the html page
6)But when i give "http://localhost:80/stockwatcher/stockwatcher/stockPricesl"
I
get below error
Server Error (500 internal server error)
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, blah blah ......

Please help. . I have been trying for hours and searched the apache sitoo ,but iam unable to get it working


Man Suraj
Someone says "Impossible is nothing". The man next him says "Let me see you licking your elbow tip!"
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15961
    
  19

Actually, a proxy does not redirect you. Apache redirection actually returns a status with the redirect target URL in it to your client and the client then re-issues the request using that URL, if I'm not mistaken.

In contrast, the proxy actually rewrites the request to make it look like it originated from Apache itself, then forwards the rewritten request to Tomcat (or wherever). The ProxyPassReverse undoes that action so that the client thinks that Apache handled the request directly.

When mixing Apache and Tomcat, always pay attention to the format of the error page. Tomcat's error pages have distinct colorings among other things, and when you get a 500 error from Tomcat, that means that the proxy is more or less working, but that there was probably an Exception thrown in the Tomcat webapp's program code.


Customer surveys are for companies who didn't pay proper attention to begin with.
Maan Suraj
Ranch Hand

Joined: Dec 20, 2007
Posts: 299
Yeah thanks for the info Tim.But the problem was that i only included "LoadModule proxy_module modules/mod_proxy.so". Later, i realised i might have to include "LoadModule proxy_http_module modules/mod_proxy_http.so" this as well.Now it redirects properly.Need to investigate the difference between those two modules.

Though above works fine, just wanted to know when do i need to use "AddModule mod_proxy.c". I saw it in apache site. But when i try to add this line in my httpd.conf file, the server itself doesnot start for me. I dont know why.Any idea?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15961
    
  19

I'm afraid that I get mine the lazy way. I'm using the OS-supplied httpd server and the requisite modules are all either setup properly in the core bundle or neatly packaged as self-configuring add-on packages. However, failing to load a module normally causes an immediate error, not the kind of subtle stuff you seem to be encountering.

Here is everything I use to proxy to a secondary server:



Maan Suraj
Ranch Hand

Joined: Dec 20, 2007
Posts: 299
Well thanks Tim.

I am awaiting more responses from others :-)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: I have trouble in setting proxy in apache server
 
Similar Threads
Help Running GlassFish bundled with Netbeans, what does Apache & IIS redirect have to do with this?
Configuring http://localhost in Tomcat/Eclipse
The requested resource is not available
Tomcat - Apache connector problem
Calling RPC present in different server