
Wednesday, August 5th, 2009
重新编译 Squid ,原来2.6 的一些参数要修改的:
关键字 protocol 变成了 proto
acl myhttp proto HTTP
no_cache 变成了 cache:
cache deny getip
加入 forwarded_for on 到 squid.conf ,可以把 客户端 IP 地址传递给后台的 Apache ,方法是采用 X-FORWARDED-FOR 的 HTTP 头。
用 PHP 抓取:
$ip = getenv(‘REMOTE_ADDR’);
if ( $ip == “127.0.0.1″ ) $ip=getenv(‘HTTP_X_FORWARDED_FOR’);
Apache 日志显示,修改日志记录方式为:
LogFormat ‘%{X-Forwarded-For}i %v %u %t “%r” %>s %b “%{Referer}i” “%{User-Agent}i”‘ cached
检查客户端 IP 地址的例子: http://myip.freelamp.com/

No Comments
Posted by albertxu in Apache, Squid 

Monday, February 27th, 2006
由 徐永久 发表于 2006年02月27日 00:33。
为什么要调戏 Baidu ,因为它愚蠢。
为什么他愚蠢? 因为它会集中,大批量的发送 Spider 信息给一个网站。
怎么调戏?两个方法:
第一个:如果是通过 Baidu 网站引用过来的,利用 Squid 的 功能提示错误信息,让用户再次点击连接才能阅读文章。 Squid 实现方法:
acl BAIDU referer_regex baidu.com
http_access deny BAIDU
deny_info ERR_BAIDU BAIDU
Read the rest of this entry »

No Comments
Posted by albertxu in Apache, Squid, defaultcat 

Saturday, November 5th, 2005
由 徐永久 发表于 2005年11月05日 20:34。
Squid 能为网站服务器提供强大的缓冲,特别是那些以数据库为后台的。
用 -z 命令重新建立 swap 目录费时较长。 用下面的办法能快速实现缓冲的清理:
先停止 Squid 然后
echo ” ” > /var/squid/caches/swap.state
然后启动 Squid 即可。

No Comments
Posted by albertxu in Squid, defaultcat 

Wednesday, May 18th, 2005
由 徐永久 发表于 2005年05月18日 15:15。
Squid 缓冲服务器能极大的提高服务器性能,特别是对于数据库负载比较大的情况下,运用 Squid 更加高效。 现在很多大型网站都利用 Squid 来加速,本文通过 PHP 代码的例子,解释了怎样利用 Cache 来实现页面缓冲。
修改前,不利用缓冲的代码:
/*
header( ‘Expires: Mon, 26 Jul 1997 05:00:00 GMT’ );
header( ‘Last-Modified: ‘ . gmdate( ‘D, d M Y H:i:s’ ) . ‘ GMT’ );
header( ‘Cache-Control: no-store, no-cache, must-revalidate’ );
header( ‘Cache-Control: post-check=0, pre-check=0′, false );
header( ‘Pragma: no-cache’ );
*/
修改后的代码:
header(“Expires: ” .gmdate (“D, d M Y H:i:s”, time() + 60 * 10). ” GMT”);
header( ‘Last-Modified: ‘ . gmdate( ‘D, d M Y H:i:s’ ) . ‘ GMT’ );
// header( ‘Last-Modified: ‘ . gmdate( ‘D, d M Y H:i:s’ )+3600 . ‘ GMT’ );
header( “Cache-Control: public” );
对于需要 Basic 认证的网页,如果需要缓冲,必须使用最后一句 public 的头。

No Comments
Posted by albertxu in Squid, defaultcat 

Tuesday, October 16th, 2001
由 徐永久 发表于 2001年10月16日 20:57。
本文对中小型企业局域网 采用 Linux 作缓冲服务器提出了解决方案。
世界已经步入 Internet 计算的时代,而这个时代的代表就是Web 服务。几年前,我们把 WWW 叫做 World Wide Wait,现在的形势虽然有所好转,但是我们浏览很多网站依然可以体会到这种感觉。笔者今天要讲的是采用 Linux 下的开放源码产品实现缓冲服务器。让我们不再“享受”等待的痛苦。
我们的缓冲服务器有两种实现模式。一种是在局域网的实现,用来加速局域网到外部 Internet 的连接。第二种是把服务器假设在Web 服务器和Internet 之间。它能缓冲客户对Web 服务器的请求,而减轻Web 服务器的负荷。性能的具体提升数值随实际网络流量的变化而变化,但是在实验室下测得的数据能达到54% 的缓冲。这意味着缓冲服务器为Web 服务器挑了一半的担子!
Read the rest of this entry »

No Comments
Posted by albertxu in Squid, defaultcat 