Re: [squid-users] My PreDefined DownLoad

From: Eliezer Croitoru <eliezer_at_ngtech.co.il>
Date: Tue, 17 Jul 2012 14:38:53 +0300

On 7/17/2012 1:59 PM, Vishal Agarwal wrote:
> Dear All,
>
> Is there any way to replace the download location for some client PC via
> squid.
>
> Like if somebody is downloading say .torrent file from any location; he
> should end up with my predefined .torrent file located in my localhost web
> server location torrent file.
>
>
> Thanks/regards,
> Vishal Agarwal
>
>
try to not hijack other people threads to keep the list in order, please.

it can be done but it's preferred to redirect them into some html page
that is saying something about restrictions of the network.
you can use the url_rewrite_program.
i wrote some url_rewriter in these examples:
http://wiki.squid-cache.org/ConfigExamples/PhpRedirectors
http://wiki.squid-cache.org/ConfigExamples/DynamicContent/Coordinator#Store_URL_Rewrite

mine uses regex to find a match.
if so will send a rewritten url to the server.
you can use it like this:
##start
#!/usr/bin/ruby
def main
   while request = gets
         request = request.split
      if request[0]
         case request[1]
           when /^http:\/\/.*\.torrent$/
             puts request[0] +
"302:http://server_ip_or_domain/302_torrent_forbidden.html"
           else
             puts request[0] + ""
         end
      else
         puts ""
      end
    end

end
STDOUT.sync = true
main
##end

Regards,
Eliezer

-- 
Eliezer Croitoru
https://www1.ngtech.co.il
IT consulting for Nonprofit organizations
eliezer <at> ngtech.co.il
Received on Tue Jul 17 2012 - 11:38:59 MDT

This archive was generated by hypermail 2.2.0 : Tue Jul 17 2012 - 12:00:02 MDT