鱿鱼 url_rewrite_program [英] Squid url_rewrite_program

查看:33
本文介绍了鱿鱼 url_rewrite_program的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用squid url_rewrite_program 去掉adf.ly 的广告.我已经写了一个 perl 脚本,我从一个例子中获取了代码,这很好用.但是我不能让它在鱿鱼中工作,它似乎没有做任何事情?

I would like to use the squid url_rewrite_program to get rid of adf.ly ads. I've already written a perl script on which I've taken the code from an example and this works fine. However I can't get it working in squid it just seems as it isn't doing anything?

我已经通过命令行测试了 perl 脚本,输出看起来完全符合我的要求.
有人可以帮忙吗?

I've tested the perl script via the command line and output looks exactly as I want it.
Can somebody help?

#!/usr/bin/perl
use strict;

# Turn off buffering to STDOUT
$| = 1;

# Read from STDIN
while (<>) {

my @elems = split; # splits $_ on whitespace by default

# The URL is the first whitespace-separated element.
my $url = $elems[0];

# Handle foo.example.com links and translate them to example.com
# with the rest of the URL intact (if present). Ignore warnings...
if ($url =~ m#^http://adf\.ly(/.*)?#i) {

    $url = substr $url, 22;

    print "$url\n";

}


else {

    # Unmodified URL
    print "$url\n";

}

}

推荐答案

对于既定的目的,这看起来像是一个过于复杂的解决方案.您可以通过基于 dstdomain acl 拒绝访问来获得更有效的结果

This looks like an overly complicated solution for the stated purpose. You can get a more effective result by denying access based on a dstdomain acl

例如acl deny_ads dstdomain .adf.lyhttp_access deny deny_ads

e.g. acl deny_ads dstdomain .adf.ly http_access deny deny_ads

这将阻止此鱿鱼的客户端访问 adf.ly 的任何子域中的任何 URL.它是同步的,不需要 DNS 查找,因此速度也非常快.

This will prevent this squid's clients from accessing any urls in any subdomain of adf.ly. It's synchronous, requires no DNS lookups so it's also very fast.

这篇关于鱿鱼 url_rewrite_program的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆