我使用的环境CentOS5.5 yum的apache2+PHP5+squid,目前网站已配置成功。
一.APACHE配置
apache(81端口)+squid(80端口)(apache和squid跑在同一个机器上面 要实现反向代理 )我将我的外网域名用abc.com代替了
apache简单配置如下:
Listen 81
NameVirtualHost *
<VirtualHost *>
<Directory [/usr/local/www/]>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Satisfy all
</Directory>
ServerName www.abc.com
ServerAdmin webadmin@abc.com
DocumentRoot [/usr/local/www/]
DirectoryIndex index.jsp
# ErrorLog [/usr/local/apache/logs/abc-error_log]
# SetEnvIf Remote_Addr [::1″ dontlog
# CustomLog [/usr/local/apache/logs/abc-access_log] combined env=!dontlog
</VirtualHost>
此时可以通过lsof -i:81查看谁占用81端口
二.SQUID配置
安装 rpm -ivh squid.3.x.rpm
配置 vi /etc/squid/squid.conf
#change for hugwww
visible_hostname blog.151051.cn
http_port 80 vhost vport
cache_peer 127.0.0.1 parent 81 0 no-query originserver
cache_peer_domain 127.0.0.1 blog.151051.cn
acl all src all
http_access allow all
cache_dir ufs /var/spool/squid 100 16 256
access_log /var/log/squid/access.log squid
cache_log /var/log/squid/cache.log
acl QueryString url_regex \.php?
no_cache deny QueryString
maximum_object_size 320010 KB
maximum_object_size_in_memory 100 KB
dns_nameservers 192.168.0.100
cache_mgr gaojinbo@dayang.com
#/usr/local/squid/sbin/squid -k parse
可以根据这个测试命令用来验证squid.conf的语法和配置(下面是OK的如果不OK会有相应的提示根据提示来修改配置文件)
2008/03/19 15:29:48| Processing Configuration File: /etc/squid.conf (depth 0)
#squid -z
用来Creating Swap Directories
还有测试命令如:squid -CNd1
[root@www ~]# cat /var/log/squid/access.log |grep TCP_MEM_HIT
该指令可以看到在squid运行过程中,有那些文件被squid缓存到内存中,并返回给访问用户
[root@www ~]# cat /var/log/squid/access.log |grep TCP_HIT
该指令可以看到在squid运行过程中,有那些文件被squid缓存到cache目录中,并返回给访问用户
[root@www ~]# cat /var/log/squid/access.log |grep TCP_MISS
该指令可以看到在squid运行过程中,有那些文件没有被squid缓存,而是现重原始服务器获取并返回给访问用户
可以查看下命中率及其他相关信息
#squidclient -p 80 -h localhost mgr:info
三.配置客户端访问
1.修改HOSTS文件,将svr-ekp.broad-ocean.com的地址设置为192.168.0.193
2.修改DNS记录,将svr-ekp.broad-ocean.com的地址设置为192.168.0.193
3.浏览器访问svr-ekp.broad-ocean.com
注:第一步骤可省略,使用现在WEB服务器.
查看更多关于squid3.0 反向代理 apache2+squid3的详细内容...