Reverse proxy? (& a one-char fix)

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Reverse proxy? (& a one-char fix)

Russell Howe
One thing I use in Apache quite a bit is the reverse proxy support
offered by mod_proxy.

Has anyone ever written something comparable for Jetty? I guess it would
best be implemented as a Handler, although it may be hackable as a
Servlet filter, even...

As for the one-char fix, in:

modules/jetty/src/main/java/org/mortbay/jetty/handler/DefaultHandler.java

Line 41 - s/favicon.ici/favicon.ico/

--
Russell Howe
[hidden email]


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Reverse proxy? (& a one-char fix)

Greg Wilkins-5
Russell Howe wrote:
> One thing I use in Apache quite a bit is the reverse proxy support
> offered by mod_proxy.
>
> Has anyone ever written something comparable for Jetty? I guess it would
> best be implemented as a Handler, although it may be hackable as a
> Servlet filter, even...

there is a proxy servlet and there may be a proxy filter in the near future.

It does not support rewritting of content - but that is also on the todo list (but
rather deep down).

cheers


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Reverse proxy? (& a one-char fix)

Russell Howe
On Fri, May 26, 2006 at 09:41:44AM +0200, Greg Wilkins wrote:

> Russell Howe wrote:
> > One thing I use in Apache quite a bit is the reverse proxy support
> > offered by mod_proxy.
> >
> > Has anyone ever written something comparable for Jetty? I guess it would
> > best be implemented as a Handler, although it may be hackable as a
> > Servlet filter, even...
>
> there is a proxy servlet and there may be a proxy filter in the near future.
>
> It does not support rewritting of content - but that is also on the todo
> list (but rather deep down).

Is that to support acting as a proxy which looks like a web server (but
which actually passes the requests on to one or more backend web
servers)?

We have apache's mod_proxy forwarding URLs which match particular
patterns on to other web servers (IIS), after applying access controls
and doing HTTP auth.

This allows us to keep a single HTTP daemon exposed to the internet at
large, but get functionality from more than one at the backend.

I thought (from a cursory glance, admittedly) that the Jetty proxy stuff
was in order that you could use Jetty as a proxy for a HTTP client, so
that you could do this:

export http_proxy=http://jetty.example.com:8080/
$httpclient http://some.url/

What I'm trying to do is use Jetty to authenticate clients using JAAS
before passing their requests on to another web server (be it apache or
IIS).

That way, we could switch our front-end web services to Jetty instead of
apache and that would be one more tickmark in netcraft's stats for Jetty
(currently, it says we run Apache when most of the work is done by
Jetty via mod_jk).

--
Russell Howe
[hidden email]


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Reverse proxy? (& a one-char fix)

Greg Wilkins-5

russell,


the old servlet handler was extensible to support this.

I see that the current ProxyServlet is not.   We just need to
put the
            String uri=request.getRequestURI();
            if (request.getQueryString()!=null)
                uri+="?"+request.getQueryString();

bit in a protocted method which you can extend to do
your own logic to work out what requests to proxy and
to where.

we will do this shortly.

cheers



[hidden email] wrote:

> On Fri, May 26, 2006 at 09:41:44AM +0200, Greg Wilkins wrote:
>> Russell Howe wrote:
>>> One thing I use in Apache quite a bit is the reverse proxy support
>>> offered by mod_proxy.
>>>
>>> Has anyone ever written something comparable for Jetty? I guess it would
>>> best be implemented as a Handler, although it may be hackable as a
>>> Servlet filter, even...
>> there is a proxy servlet and there may be a proxy filter in the near future.
>>
>> It does not support rewritting of content - but that is also on the todo
>> list (but rather deep down).
>
> Is that to support acting as a proxy which looks like a web server (but
> which actually passes the requests on to one or more backend web
> servers)?
>
> We have apache's mod_proxy forwarding URLs which match particular
> patterns on to other web servers (IIS), after applying access controls
> and doing HTTP auth.
>
> This allows us to keep a single HTTP daemon exposed to the internet at
> large, but get functionality from more than one at the backend.
>
> I thought (from a cursory glance, admittedly) that the Jetty proxy stuff
> was in order that you could use Jetty as a proxy for a HTTP client, so
> that you could do this:
>
> export http_proxy=http://jetty.example.com:8080/
> $httpclient http://some.url/
>
> What I'm trying to do is use Jetty to authenticate clients using JAAS
> before passing their requests on to another web server (be it apache or
> IIS).
>
> That way, we could switch our front-end web services to Jetty instead of
> apache and that would be one more tickmark in netcraft's stats for Jetty
> (currently, it says we run Apache when most of the work is done by
> Jetty via mod_jk).
>



-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Reverse proxy? (& a one-char fix)

Pier Fumagalli-2
On 26 May 2006, at 11:20, Greg Wilkins wrote:

>
> russell,
>
>
> the old servlet handler was extensible to support this.
>
> I see that the current ProxyServlet is not.   We just need to
> put the
>             String uri=request.getRequestURI();
>             if (request.getQueryString()!=null)
>                 uri+="?"+request.getQueryString();
>
> bit in a protocted method which you can extend to do
> your own logic to work out what requests to proxy and
> to where.
>
> we will do this shortly.
>
> cheers
I wrote a small servlet (well, modified something that came with  
Jetty) that does exactly that (see attachment). To configure I  
normally do something like this:

        Pier

<?xml version="1.0"  encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure  
1.0//EN" "http://jetty.mortbay.org/configure_1_1.dtd">

<Configure class="org.mortbay.jetty.Server">

   <Call name="addListener">
     ...
   </Call>


   <Call name="addContext">
     <Arg>/</Arg>

     <Call name="setInitParameter">
       <Arg>proxy</Arg>
       <Arg>http://localhost:8888/live/it/vnu/</Arg>
     </Call>

     <Call name="addServlet">
       <Arg>proxy</Arg>
       <Arg>/*</Arg>
       <Arg>ProxyServlet</Arg>
     </Call>
   </Call>

</Configure>


ProxyServlet.java (4K) Download Attachment
smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: Reverse proxy? (& a one-char fix)

james lee-13
In reply to this post by Russell Howe
On 26/05/06, 10:36:13, <[hidden email]> wrote regarding Re:
[jetty-discuss] Re: Reverse proxy? (& a one-char fix):


> Is that to support acting as a proxy which looks like a web server (but
> which actually passes the requests on to one or more backend web
> servers)?

> We have apache's mod_proxy forwarding URLs which match particular
> patterns on to other web servers (IIS), after applying access controls
> and doing HTTP auth.

> This allows us to keep a single HTTP daemon exposed to the internet at
> large, but get functionality from more than one at the backend.

I'd be interested in this too.  Currently the majority of my pages
come from Jetty but because a few need to go another server I use
Apache in front of all the pages and most just redirect to Jetty via
mod_proxy.  I'd prefer Jetty to handle this majority directly and use
Jetty to proxy the minority.

Some of my content is static but Jetty serves this perfectly well.
Using Jetty for the static uses less total memory, Jetty's log rolling
saves using cronolog/logrotate and it is simpler to use just one system.



> That way, we could switch our front-end web services to Jetty instead of
> apache and that would be one more tickmark in netcraft's stats for Jetty
> (currently, it says we run Apache when most of the work is done by
> Jetty via mod_jk).

If you use mod_proxy it shows as Jetty, eg:
http://uptime.netcraft.com/up/graph?site=www.canoedescent.org.uk




James.


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Reverse proxy? (& a one-char fix)

Russell Howe
In reply to this post by Pier Fumagalli-2
Pier Fumagalli wrote, sometime around 26/05/06 11:35:
> I wrote a small servlet (well, modified something that came with Jetty)
> that does exactly that

Oh cool - I'll give this a try, thanks!

Just from a quick look at the code, I think I spotted a typo:

--- ProxyServlet.java.orig 2006-05-26 11:56:27.366259397 +0100
+++ ProxyServlet.java 2006-05-26 11:56:38.469981981 +0100
@@ -61,7 +61,7 @@
                 String name = (String) names.nextElement();
                 String check = name.toLowerCase();
                 if ("content-type".equals(check)) hasContent = true;
-                if ("content-lenght".equals(check)) hasContent = true;
+                if ("content-length".equals(check)) hasContent = true;
                 if ("host".equals(check)) continue;

                 Enumeration values = req.getHeaders(name);

--
Russell Howe
[hidden email]


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Reverse proxy? (& a one-char fix)

Russell Howe
In reply to this post by Pier Fumagalli-2
Pier Fumagalli wrote, sometime around 26/05/06 11:35:
> I wrote a small servlet (well, modified something that came with Jetty)
> that does exactly that (see attachment). To configure I normally do
> something like this:

I had to do this to get it to recognise the init parameter under Jetty
5.1.3. I'm not sure if what I'd did was 'right' yet (I'm just hacking
around to get the thing to work for now), but it seems to be the way
that "Core Servlets and JSP" (yeah, I know it's old) suggests an init
method should be done.

--- ProxyServlet.java.orig 2006-05-26 11:56:27.366259397 +0100
+++ ProxyServlet.java 2006-05-26 13:11:03.622471252 +0100
@@ -7,6 +9,7 @@
 import java.util.Enumeration;

 import javax.servlet.GenericServlet;
+import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
@@ -22,10 +25,11 @@
         super();
     }

-    public void init()
+    public void init(ServletConfig config)
     throws ServletException {
+     super.init(config);
         final ServletContext context = this.getServletContext();
-        final String base = (String) context.getInitParameter("proxy");
+        final String base = (String) config.getInitParameter("proxy");
         if (base == null) throw new ServletException("No parameter
\"proxy\"");
         try {
             if (base.endsWith("/")) this.base = new URI(base).toURL();

--
Russell Howe
[hidden email]


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss