You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Marc Stern <ma...@approach.be> on 2007/02/20 10:36:10 UTC

Using mod_proxy from another module

How could we use mod_proxy for outgoing connections from another module ?
Is there any simple way ?
Is there any standard (I mean documented) way, or would it rely on 
internals only ? In the latter case, we would have to recode everything 
when mod_proxy changes.

Thanks

Marc

Re: Using mod_proxy from another module

Posted by Graham Leggett <mi...@sharp.fm>.
On Tue, February 20, 2007 11:36 am, Marc Stern wrote:

> How could we use mod_proxy for outgoing connections from another module ?
> Is there any simple way ?
> Is there any standard (I mean documented) way, or would it rely on
> internals only ? In the latter case, we would have to recode everything
> when mod_proxy changes.

Probably the best way to do this it to trigger a subrequest that is
handled by mod_proxy. Subrequests are a standard part of the httpd
internals.

mod_include is an example of a module that triggers subrequests that are
then incorporated into the main request.

Regards,
Graham
--



Re: Using mod_proxy from another module

Posted by Marc Stern <ma...@approach.be>.
I can't find how to do that, could you help me ?

Thanks,

Marc
 
*//*

Jim Jagielski wrote:
> Yep. No problem.
>
> On Feb 21, 2007, at 4:50 AM, Marc Stern wrote:
>
>> Is it also possible to make a post with this ?
>> This is what I need.
>>
>>
>> Jim Jagielski wrote:
>>>> How could we use mod_proxy for outgoing connections from another 
>>>> module ?
>>>> Is there any simple way ?
>>>> Is there any standard (I mean documented) way, or would it rely on 
>>>> internals only ? In the latter case, we would have to recode 
>>>> everything when mod_proxy changes.
>>>>
>>>
>>> You would do something like this:
>>>
>>>     rr = ap_sub_req_method_uri("OPTIONS", "*", r, NULL); /* this 
>>> MUST succeed! */
>>>     apr_snprintf(newurl, sizeof(newurl),
>>>                 "proxy:%s://%s:%d/%s",
>>>                 protocol, sendToIP, sendToPort, myURL);
>>>     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
>>>                                 "query constructed: %s", newurl);
>>>     rr->filename = apr_pstrdup(r->pool, newurl);
>>>     rr->proxyreq = PROXYREQ_REVERSE;
>>>     rr->handler  = "proxy-server";
>>>     ap_run_sub_req(rr);
>>>
>>> and then use the response as needed... The above I've used
>>> in some where I'm just interested in getting some backend
>>> header info...
>>>
>>
>
>

Re: Using mod_proxy from another module

Posted by Jim Jagielski <ji...@jaguNET.com>.
Yep. No problem.

On Feb 21, 2007, at 4:50 AM, Marc Stern wrote:

> Is it also possible to make a post with this ?
> This is what I need.
>
>
> Jim Jagielski wrote:
>>> How could we use mod_proxy for outgoing connections from another  
>>> module ?
>>> Is there any simple way ?
>>> Is there any standard (I mean documented) way, or would it rely  
>>> on internals only ? In the latter case, we would have to recode  
>>> everything when mod_proxy changes.
>>>
>>
>> You would do something like this:
>>
>>     rr = ap_sub_req_method_uri("OPTIONS", "*", r, NULL); /* this  
>> MUST succeed! */
>>     apr_snprintf(newurl, sizeof(newurl),
>>                 "proxy:%s://%s:%d/%s",
>>                 protocol, sendToIP, sendToPort, myURL);
>>     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
>>                                 "query constructed: %s", newurl);
>>     rr->filename = apr_pstrdup(r->pool, newurl);
>>     rr->proxyreq = PROXYREQ_REVERSE;
>>     rr->handler  = "proxy-server";
>>     ap_run_sub_req(rr);
>>
>> and then use the response as needed... The above I've used
>> in some where I'm just interested in getting some backend
>> header info...
>>
>


Re: Using mod_proxy from another module

Posted by Marc Stern <ma...@approach.be>.
Is it also possible to make a post with this ?
This is what I need.


Jim Jagielski wrote:
>> How could we use mod_proxy for outgoing connections from another 
>> module ?
>> Is there any simple way ?
>> Is there any standard (I mean documented) way, or would it rely on 
>> internals only ? In the latter case, we would have to recode 
>> everything when mod_proxy changes.
>>
>
> You would do something like this:
>
>     rr = ap_sub_req_method_uri("OPTIONS", "*", r, NULL); /* this MUST 
> succeed! */
>     apr_snprintf(newurl, sizeof(newurl),
>                 "proxy:%s://%s:%d/%s",
>                 protocol, sendToIP, sendToPort, myURL);
>     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
>                                 "query constructed: %s", newurl);
>     rr->filename = apr_pstrdup(r->pool, newurl);
>     rr->proxyreq = PROXYREQ_REVERSE;
>     rr->handler  = "proxy-server";
>     ap_run_sub_req(rr);
>
> and then use the response as needed... The above I've used
> in some where I'm just interested in getting some backend
> header info...
>

Re: Using mod_proxy from another module

Posted by Jim Jagielski <ji...@jaguNET.com>.
On Feb 20, 2007, at 4:36 AM, Marc Stern wrote:

> How could we use mod_proxy for outgoing connections from another  
> module ?
> Is there any simple way ?
> Is there any standard (I mean documented) way, or would it rely on  
> internals only ? In the latter case, we would have to recode  
> everything when mod_proxy changes.
>

You would do something like this:

	rr = ap_sub_req_method_uri("OPTIONS", "*", r, NULL); /* this MUST  
succeed! */
	apr_snprintf(newurl, sizeof(newurl),
                 "proxy:%s://%s:%d/%s",
                 protocol, sendToIP, sendToPort, myURL);
	ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                                 "query constructed: %s", newurl);
	rr->filename = apr_pstrdup(r->pool, newurl);
	rr->proxyreq = PROXYREQ_REVERSE;
	rr->handler  = "proxy-server";
	ap_run_sub_req(rr);

and then use the response as needed... The above I've used
in some where I'm just interested in getting some backend
header info...