You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Anita Hussain <an...@yahoo.com> on 2003/04/12 08:21:41 UTC

Re: Writing Proxy Servlets WAS Re: Way to create a Default servlet?

Hi

I'm trying to write a Proxy servlet on Tomcat, and am
running into similar problems as described in this
email thread attached below. Now i realize this thread
is old, and the Tomcat version that i'm using is
4.1.24. Is this functionality still not supported in
the latest Tomcat version?

To summarize, I'm trying to write a Proxy servlet that
sits as a default servlet on Tomcat and is supposed to
 receive all the http reqests sent through
localhost:8080. However when i try to GET a remote URL
like www.yahoo.com from my client browser which is set
to use the localhost:8080 as the proxy, my Proxy
Servlet just doesn't respond!! For requests sites on
my localhost, the servlet seems to be responding ok.

Can someone please confirm if Tomcat still doesn't
support this facility or am i missing something?

Thanks!
Anita


To: tomcat-user@jakarta.apache.org 
Subject: Re: Writing Proxy Servlets WAS Re: Way to
create a Default servlet? 
Date: Tue, 18 Apr 2000 10:48:52 -0700 
From: "Craig R. McClanahan"  

Ivan Stork wrote:

> Thanks, Hans. The fix you gave works great.
> Anyone else attempted to write a proxy servlet using
Tomcat?
> The problem I'm having is if I try to GET
http://www.yahoo.com (by telneting to
> localhost 8080) I get a 400 Bad Request.
> It seems like my GET method only works for pages
within the local site? (Works
> o.k. for GET /index.html
> Is this a Tomcat thing, or am I not writing my
servlet correctly?
>

Tomcat does not currently support absolute URLs in the
request URI, so you cannot
currently write a proxy in this way.

One thing that was experimented with earlier, but is
also not currently suported, is a
means to let the document root of your web application
live on a remote server, instead
of in the local file system.  Then, you could sort of
proxy by setting up a context
like this:

    <Context path="/yahoo"
docBase="http://www.yahoo.com"/>

and refer to Yahoo pages through Tomcat like this:

   
http://localhost:8080/yahoo/{yahoo-relative-URL-here}

of course, hyperlinks on these pages only work if they
are relative, not absolute, so
it isn't a real proxy -- but it would support one form
of load balancing.

I'm looking at various ways that this functionality
might be restored to Tomcat --
there's a bunch of interesting issues related to
accessing resources (for example, how
do you tell if a JSP page has been modified so you can
recompile it) that have to be
adjusted to work in this kind of a situation.

Craig McClanahan

To: tomcat-user@jakarta.apache.org 
Subject: Re: Way to create a Default servlet? 
From: Hans Bergsten <ha...@gefionsoftware.com> 
Date: Mon, 17 Apr 2000 22:38:30 -0700 
Delivered-To: mailing list
tomcat-user@jakarta.apache.org 
list-help:
<ma...@jakarta.apache.org> 
list-post: <ma...@jakarta.apache.org> 
list-unsubscribe:
<ma...@jakarta.apache.org> 
Mailing-List: contact
tomcat-user-help@jakarta.apache.org; run by ezmlm 
Organization: Gefion software 
References: <00...@harpua> 
Reply-To: tomcat-user@jakarta.apache.org 

--------------------------------------------------------------------------------

Ivan Stork wrote:
> 
> Hi, I'm trying to write my own proxy server. (I need
to add some custom headers
> to every HTTP request) I'm adapting a simple servlet
to be the proxy server.
> I'd like to set it up to handle EVERY request to
http://localhost:8080
> 
> I edited the web.xml in
/opt/tomcat/webapps/ROOT/WEB-INF to this:
> 
> <web-app>
> 
> <servlet>
> <servlet-name>
> FCProxy
> </servlet-name>
> <servlet-class>
> FCProxy
> </servlet-class>
> </servlet>
> 
> <servlet-mapping>
>     <servlet-name>
>         FCProxy
>     </servlet-name>
>     <url-pattern>
>     *.fff
>     </url-pattern>
> </servlet-mapping>
> 
> </web-app>
> 
> This works for all files ending in .fff. I have
tried * and *.* to capture all
> files, but I can't get either to work.

If you want one servlet to handle all requests, remove
all other mappings
and define a mapping for the default servlet pattern:

  <servlet-mapping>
      <servlet-name>
          FCProxy
      </servlet-name>
      <url-pattern>
          /
      </url-pattern>
  </servlet-mapping>

Note! There were some problems with this until very
recently, so make sure
you grab the latest nightly build (or the latest
source from CVS).

Hans




__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org