0

Is there any option in Squid that allow me to change packets dynamically?

For ex: I want to send all packet that comming to Squid to my PHP code and change the packet with PHP Dynamically and resend it to Squid.

3 Answers3

0

If I am understanding your question correctly you are looking for the url_rewrite_program directive.

There is even an example using php and ofcourse there a lot more fun examples in April Fools Pranks with a Squid Proxy Server even though all of them are in perl.

thanosk
  • 940
  • 7
  • 16
0

From your vague question I guess you want to do something for the HTTP headers or request URIs.

For that you can use url_rewrite_* parameters in Squid. For example, configuring Squid to use some PHP script for determining the correct URL you could put

url_rewrite_program /path/to/your/script/squid_url_rewrite.php

in Squid config and make sure your PHP script finally returns something like 302:http://www.example.com/.

Janne Pikkarainen
  • 31,852
  • 4
  • 58
  • 81
  • Thank you for your answer, I know 'url_rewrite_program' exist in squid but I can't modify all data that I want, I can just rewrite URLs in packets. – Jessica Oct 13 '14 at 17:36
0

Squid starting from version 3 can act as an ICAP client. If you manage to build your own ICAP server or a plugin to already existing C-ICAP server (for example) then you will be able to filter contents of HTTP(s) requests and responses and not only URLs as in case of url rewriter. See the description at http://wiki.squid-cache.org/Features/ICAP and list of already existing ICAP servers at http://www.squid-cache.org/Misc/icap.html.

Rafael
  • 534
  • 2
  • 3