利用squidclient清理nginx多台缓存服务器cgi程序

此cgi脚本用perl写的,用于清理多台nginx缓存服务器。
使用方法:将此脚本放在能够执行cgi程序的web服务器上。
打开浏览器访问此脚本,输入需要清理缓存的CSS或者是图片地址,如果要清理多个缓存,请一行输入一个地址即可。
code:
#!/usr/bin/perl
use strict;
use warnings;
use CGI;

my $req = new CGI;
print $req->header;
print << HTML;
< form method = "post" action = "post.cgi" name = "form" > < textarea name = url rows = 5 cols = 60 > < / textarea > < P > < input type = submit > < input type = reset > < / form > HTML my $url = $req->param("url");
  $url = ~tr / + //;
  $url = ~s / % ([a - fA - F0 - 9][a - fA - F0 - 9]) / pack("C", hex($1)) / eg;

my @ url = split / \ n /, $url;
foreach (@ url) {
  my $purge_url = $_;
  if (/ http : \ / \ / (\ S + ?) (? = \ /) /) {
    if ($1) {
      my $squid_req = system("squidclient -h$1 -p80 -mPURGE $purge_url");
      print $squid_req;
    }
  }

}

你可能感兴趣的:(cgi,perl,purge,squidclient,清理多台nginx缓存)