You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Jodi Bosa <jo...@gmail.com> on 2011/11/01 18:09:57 UTC

mod_proxy retry

I'm looking for a filter that works with mod_proxy to resubmit a request to
a server based on something being present in a response.

In other words:

   - client browser directs request through proxy
   - mod_proxy sends request to server
   - proxy receives response, parses response, and then possibly resubmits
   the request to the same server again


I couldn't spot anything useful in mod_proxy config, and figured should be
simple enough in an output filter - but how to trigger the resubmit of the
request?

Thanks.

Re: mod_proxy retry

Posted by Sorin Manolache <so...@gmail.com>.
On Fri, Nov 4, 2011 at 01:18, Jodi Bosa <jo...@gmail.com> wrote:
> thanks but unfortunately it seems mod_include #include virtual does not
> appear to support requests to external servers (must not contain a scheme
> or hostname - only path and query string).
>
>
> Regardless, I also tried ap_sub_req_lookup_uri():
>
>
>   static apr_status_t x_response_filter(ap_filter_t *f, apr_bucket_brigade
> *bb)
>   {
>        request_rec                                             *r, *subr;
>        int
> status;
>
>        request_rec *subr = ap_sub_req_lookup_uri("http://www.apache.org",
> r, f->next);
>        status = ap_run_sub_req(subr);
>        ap_destroy_sub_req(subr);
>   }
>
>
> which seemed to succeed to make_sub_request() but later on mod_proxy's
> proxy_handler() failed because of r->proxyreq was NULL.
>

You can still do it with ap_sub_req_lookup_uri. Just use something like

RewriteEngine On
RewriteRule /dummy/path http://external.proxy/path2 [P]

and then ap_sub_req_method_uri("GET", "/dummy/path", r, f->next);

The [P] in the rewriterule makes sure you have r->proxyreq not null.

S

Re: mod_proxy retry

Posted by Jodi Bosa <jo...@gmail.com>.
thanks but unfortunately it seems mod_include #include virtual does not
appear to support requests to external servers (must not contain a scheme
or hostname - only path and query string).


Regardless, I also tried ap_sub_req_lookup_uri():


   static apr_status_t x_response_filter(ap_filter_t *f, apr_bucket_brigade
*bb)
   {
        request_rec                                             *r, *subr;
        int
status;

        request_rec *subr = ap_sub_req_lookup_uri("http://www.apache.org",
r, f->next);
        status = ap_run_sub_req(subr);
        ap_destroy_sub_req(subr);
   }


which seemed to succeed to make_sub_request() but later on mod_proxy's
proxy_handler() failed because of r->proxyreq was NULL.

Should I carry on this path or is there some other functionality in
mod_proxy such that I can initiate a request to an *EXTERNAL* server from
within a response filter?

many thanks



On Tue, Nov 1, 2011 at 2:02 PM, Nick Kew <ni...@apache.org> wrote:

> On Tue, 1 Nov 2011 13:09:57 -0400
> Jodi Bosa <jo...@gmail.com> wrote:
>
> > I couldn't spot anything useful in mod_proxy config, and figured should
> be
> > simple enough in an output filter - but how to trigger the resubmit of
> the
> > request?
>
> If the response is HTML, mod_includes will parse it.  It'll also submit
> another request via #include virtual.
>
>
> --
> Nick Kew
>

Re: mod_proxy retry

Posted by Nick Kew <ni...@apache.org>.
On Tue, 1 Nov 2011 13:09:57 -0400
Jodi Bosa <jo...@gmail.com> wrote:

> I couldn't spot anything useful in mod_proxy config, and figured should be
> simple enough in an output filter - but how to trigger the resubmit of the
> request?

If the response is HTML, mod_includes will parse it.  It'll also submit
another request via #include virtual.


-- 
Nick Kew