Writting a simple proxy in PHP

This is a discussion on Writting a simple proxy in PHP within the PHP General forums, part of the PHP Programming Forums category; I would like to forward on the server side (also called "proxy" or "server-side redirect") ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-06-2007
Alessandro Vernet
 
Posts: n/a
Default Writting a simple proxy in PHP


I would like to forward on the server side (also called "proxy" or
"server-side redirect") some queries that get to my PHP script. A naive
approach is to do:

print(implode("", file("http://localhost:8090" . $REQUEST_URI)));

Where http://localhost:8090 is the address I want to proxy to. But of
course, this only works for simple GET requests. It does not forward headers
(like Authentication), and won't work if the request is a POST.

Has anyone a suggestion on how I could implement a better proxy? I am not
looking for a perfect solution. Something that would forward headers and
handle posts would be good enough.

Alex
--
View this message in context: http://www.nabble.com/Writting-a-sim....html#a8819622
Sent from the PHP - General mailing list archive at Nabble.com.
Reply With Quote
  #2 (permalink)  
Old 02-06-2007
Jochem Maas
 
Posts: n/a
Default Re: [PHP] Writting a simple proxy in PHP

Alessandro Vernet wrote:
> I would like to forward on the server side (also called "proxy" or
> "server-side redirect") some queries that get to my PHP script. A naive
> approach is to do:
>
> print(implode("", file("http://localhost:8090" . $REQUEST_URI)));
>
> Where http://localhost:8090 is the address I want to proxy to. But of
> course, this only works for simple GET requests. It does not forward headers
> (like Authentication), and won't work if the request is a POST.
>
> Has anyone a suggestion on how I could implement a better proxy? I am not
> looking for a perfect solution. Something that would forward headers and
> handle posts would be good enough.


if your using apache then you should look at the ProxyPass directive - very hand,
STW or STA for more detailed info.

>
> Alex

Reply With Quote
  #3 (permalink)  
Old 02-06-2007
Casey Chu
 
Posts: n/a
Default Re: [PHP] Writting a simple proxy in PHP

Try using cUrl.

On 2/6/07, Jochem Maas <jochem@iamjochem.com> wrote:
> Alessandro Vernet wrote:
> > I would like to forward on the server side (also called "proxy" or
> > "server-side redirect") some queries that get to my PHP script. A naive
> > approach is to do:
> >
> > print(implode("", file("http://localhost:8090" . $REQUEST_URI)));
> >
> > Where http://localhost:8090 is the address I want to proxy to. But of
> > course, this only works for simple GET requests. It does not forward headers
> > (like Authentication), and won't work if the request is a POST.
> >
> > Has anyone a suggestion on how I could implement a better proxy? I am not
> > looking for a perfect solution. Something that would forward headers and
> > handle posts would be good enough.

>
> if your using apache then you should look at the ProxyPass directive - very hand,
> STW or STA for more detailed info.
>
> >
> > Alex

>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply With Quote
  #4 (permalink)  
Old 02-06-2007
Alessandro Vernet
 
Posts: n/a
Default Re: [PHP] Writting a simple proxy in PHP



Jochem Maas wrote:
>
> if your using apache then you should look at the ProxyPass directive -
> very hand,
> STW or STA for more detailed info.
>


Jochem,

I went this route. I agree, it is much simpler than trying to hack this in
PHP.

Alex
--
View this message in context: http://www.nabble.com/Writting-a-sim....html#a8832985
Sent from the PHP - General mailing list archive at Nabble.com.
Reply With Quote
  #5 (permalink)  
Old 02-06-2007
Jochem Maas
 
Posts: n/a
Default Re: [PHP] Writting a simple proxy in PHP

Alessandro Vernet wrote:
>
> Jochem Maas wrote:
>> if your using apache then you should look at the ProxyPass directive -
>> very hand,
>> STW or STA for more detailed info.
>>

>
> Jochem,
>
> I went this route. I agree, it is much simpler than trying to hack this in
> PHP.


it's rather a neat way of solving the 'how to run php4 & php5 module on the same
server' problem one often encounters,

I can't take any credit though - that belongs to Rasmus Lerdorf for pointing it out
(and possibly also due to his work on Apache itself - IIRC).

regardless, nice to know you solved your problem (or at least pushed back the urgency -
I guess that one day we'll all have to let go of php4 altogether :-).

>
> Alex

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:14 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0