squid3.0反向代理 apache2+squid3
Author:gaojinbo
Time:2009-12-22
squid3.0反向代理 apache2+squid3
一.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 svr-centos5.broad-ocean.com
http_port 80 vhost vport
cache_peer 192.168.0.21 parent 80 0 no-query originserver
cache_peer_domain 192.168.0.21 svr-ekp.broad-ocean.com
#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服务器.
完成!
九月 25th, 2010 at 04:52
量子场英语…
量子场英语…
六月 3rd, 2011 at 02:44
My Recommended Websites…
[...]some new websites on the web we love, even if they are not related to ours. Check them out[...]…
七月 10th, 2011 at 07:39
Gems form the internet…
[...]very few websites that happen to be detailed below, from our point of view are undoubtedly well worth checking out[...]……
八月 27th, 2011 at 03:01
You should check this out……
[...] Wonderful story, reckoned we could combine a few unrelated data, nevertheless really worth taking a look, whoa did one learn about Mid East has got more problerms as well [...]………