开发者

Squid 301/302 redirect failed?

I am new to squid and I want to use it(squid 2.7) for redirect, e.g. www.baidu.com --> www.google.com. So I enabled the redirect module in squid by using a perl script:

#!/usr/bin/perl
$|=1;
    while (<>) {
            @X = split;
            $url = $X[0];
            if ($url =~ /^http:\/\/www\.baidu\.com/) {
                    print “302:https:\/\/www\.google\.com\n”;
            }    
            else {
                    print “$url\n”;
            }
        }

In squid.conf add:

rewrite_program /etc/squid/redirect.pl
redirect_rewrites_host_header off
redirect_children 20

The client browser failed of accessing this web page, I checked the packets over the wire:

client --> proxy  HTTP GET http://www.baidu.com/ HTTP/1.1
proxy  --> client HTTP HTTP/1.0 301 Moved Permanently

Then the client browser just waited there with no follo开发者_运维技巧w up traffic.

Anyone know the reason?

And what is the difference between redirect_program / url_rewrite_program / location_rewrite_program

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜