0

I need to configure a proxy on a machine A in a network X. Then I need to connect a client (smartphone) on this same network X but having the proxy configuration as the one prepared on the machine A. So basically, the smartphone is going to pass through Machine A before reaching internet and receiving the remote response.

I tried with Apache and his mod_proxy.so module.

What I really need to do, it's that when the client (smartphone) asks for an specific URL (Google i.e.), the Proxy Server have to filter the request and send it to a PHP script programmed to attend the request and send an specific answer to the client (and NOT the remote server response original one). For all the other requests (webs and sites), everything is going to be normal (not filtered by the proxy server).

I tried with a Forward Proxy on Apache, but I just get the tracking on the log access file. Nothing more. I can't create a "redirection" for specific requests.

Then I thought of a Reverse Proxy, trying to redirect the specific ones to a local place via ProxyPass and ProxyPassReverse. Didn't worked. Seems that Reverse Proxy only works for local asks to be resolved on the exterior or interior. But not to work for resolving exterior requests to a local ones.

Then I tried to play with mod_ext_filter.so, and played with "SetOutputFilter", creating a call to php.exe (Windows implementation) and a particular test.php script to print the $_SERVER array, and I managed to view the correct REQUEST_URI from my smartphone (client), printing a file to "C:\".

But then, when script finishes, the client receives no answer. So this doesn't seems to be the good approach too.

What should I do? Someone talked to me about SQUID and Content Adaptation, but I'm not sure about it.

Starfish
  • 2,716
  • 24
  • 28
Lightworker
  • 173
  • 1
  • 1
  • 7

1 Answers1

0

Squid with an external redirector will do exactly what you want. You'll have it rewrite certain requests to point to the PHP script on your local server, while allowing other requests to pass through to the Internet.

An external redirector is simply a small program that receives requests from squid on stdin, rewrites them as necessary, and then returns them to squid on stdout.

larsks
  • 41,276
  • 13
  • 117
  • 170
  • Mmmm... pretty much interesting. Thanks! I'm going to take a look on it. Anyway, just imagine that the client (smartphone) is waiting for an XML response. I would want to create my own XML on PHP module on the proxy machine for a certain requests (URL). So what I really need to modify (create) is the content of the response to the client and not the HTTP header itself... is it possible with this? Thanks! – Lightworker Jan 22 '11 at 12:31
  • When using the redirector, you are responsible for generating the entire response -- header and data. – larsks Jan 22 '11 at 13:36
  • Hell yes! So I'm going to take a huge look on this! Man, you make my day! When I tried and if it works, I'm going to "tick" you answer ;) Thanks! – Lightworker Jan 22 '11 at 14:33
  • Fun reading: [upside-down images with a squid redirector](http://www.ex-parrot.com/pete/upside-down-ternet.html) – larsks Jan 22 '11 at 15:59
  • LoooooL! Great one! :D – Lightworker Jan 22 '11 at 18:16
  • Oh! I've tried to play a little bit more with Apache, and I finally got results too! I'll try Squid, cause I want to meet it, but I finally managed to play with Output and Input filters, and playing with STDIN and STDOUT in PHP. :) I'll probably explain the propper solution after. – Lightworker Jan 22 '11 at 18:18