Sending Messages to Squid Proxy Users

2019-08-13 18:58发布

Is it possible to send custom HTML messages to users when they first start a session through a squid proxy server?

I want to be able to redirect a users first request to the "message of the Day".... then the rest of their browsing requests for the remainder of the session go without being redirected..... Detailed Steps:

  1. User opens browser. (Browser is configured to use the Squid Proxy)
  2. User opens http://google.com (or other url of their choice)
  3. Instead of getting Google.com they are redirected to http://somewhere.else.com/MOD.html
  4. User reads the MOD
  5. User types http://google.com again (or other url of their choice) This time the browser goes to the correct destination with no redirection.

Would I have to develop or locate a Squid Proxy Server Plug-in to perform this kind of action or is this something the SQUID server can do with a little custom code?? (Perl etc)

2条回答
ら.Afraid
2楼-- · 2019-08-13 19:38

I came across a good book on Squid titled Squid Proxy Server 3.1: Beginner's Guide by Packt. You can read more about it here https://www.packtpub.com/squid-proxy-server-31-beginners-guide/book. Maybe it will come in handy

查看更多
在下西门庆
3楼-- · 2019-08-13 19:49

There's a line in the squid conf you can add like redirect_script. Write a Perl program that takes input - one URL per line. It outputs the url you are going to redirect the user to. The UpsideDownTernet script is an example.

Now change the script to output your MOTD the first time, and every other time just echo the URL back.

The problem is, how do you tell user requests apart? Well at this point you need to use a redirect_program line instead of redirect_script...

Squid will pass in several arguments to the program:

 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"

Reference: http://taz.net.au/block/

At that point you can modify your script to determine the "timeout" each user gets between seeing the MOTD (e.g. if he doesn't visit a website for 12 hours, he gets the message) or whatever.

查看更多
登录 后发表回答