向Squid代理用户发送消息

时间:2009-04-07 16:48:44

标签: perl unix redirect proxy

是否可以在用户首次启动时向用户发送自定义HTML消息 通过squid代理服务器进行会话?

我希望能够将用户的第一个请求重定向到“消息” 一天“......然后剩余的浏览请求剩下的 会话没有被重定向..... 详细步骤:

  1. 用户打开浏览器。 (浏览器配置为使用Squid代理)
  2. 用户打开http://google.com(或其他自己选择的网址)
  3. 不是将Google.com重定向到http://somewhere.else.com/MOD.html
  4. 用户阅读MOD
  5. 用户再次输入http://google.com(或他们选择的其他网址)这一次 浏览器转到正确的目的地,没有重定向。
  6. 我是否必须开发或定位Squid Proxy Server插件才能执行此操作 某种行为,或者这是SQUID服务器可以用一点自定义做的事情 码?? (Perl等)

2 个答案:

答案 0 :(得分:3)

你可以添加像redirect_script一样的squid conf中的一行。编写一个带输入的Perl程序 - 每行一个URL。它输出您要将用户重定向到的URL。 UpsideDownTernet脚本就是一个例子。

现在更改脚本以便第一次输出您的MOTD,并且每隔一次只回显一次URL。

问题是,您如何区分用户请求?那么此时你需要使用redirect_program行而不是redirect_script ...

Squid会将几个参数传递给该程序:

 URL ip-address/fqdn ident method

 URL    is the URL requested
 ip-address/fqdn    is the IP address or fully qualified domain name of the client   (web browser) which requested the page.
 ident  is the identity of the user running the web browser. Unless you configure   squid to do ident lookups, this will be "-".
 method is the request method: "GET", "POST", "HEAD"

参考:http://taz.net.au/block/

此时你可以修改你的脚本以确定每个用户在看到MOTD之间获得的“超时”(例如,如果他没有访问网站12小时,他得到消息)或其他什么。

答案 1 :(得分:1)

我遇到了一本关于Squid的好书,名为Squid Proxy Server 3.1:Packt的初学者指南。您可以在此处详细了解https://www.packtpub.com/squid-proxy-server-31-beginners-guide/book。也许它会派上用场