Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

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.

share|improve this answer

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/.

share|improve this answer
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

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.