how to achieve temporary page in squid 3?

ningning2 asked:

I’m trying to achieve a temporary announcement page for all the client requests, which means this page will disappear after a few seconds and the URL will be back to the original client request. I also tried the url_rewrite_program in perl like below and deny_info (& allow localhost ) acl for this, but both failed. does anybody have a better idea for this? I really need your help. thanks!

#!/usr/bin/perl
use strict;
use warnings;

my @X;
my $url="";

$| = 1;

while (<>)
{
  @X = split;
  $url = $X[0];
  print "302:http://announcement.txtn";
  sleep 5;
  print "$urln";
}

My answer:


You have squid, so forget about trying to code it yourself and use squid’s built-in splash page functionality.

This 3.2+ example from the squid page will show the splash page /etc/squid/splash.html once per hour (see that page for more examples and full instructions, including examples for squid prior to 3.2):

# mind the wrap. this is one line:
external_acl_type splash_page ttl=60 concurrency=100 %SRC /usr/local/sbin/squid/ext_session_acl -t 7200 -b /var/lib/squid/session.db

acl existing_users external splash_page

http_access deny !existing_users

# Deny page to display
deny_info 511:/etc/squid/splash.html existing_users

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.